From f872504b4181d6d2136aa003f15eac6389c18fa1 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 26 Feb 2019 17:33:27 +0000 Subject: [PATCH 1/6] debian: Drop Debian support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This a relic from being hosted in Endless’ GitHub, and being built directly for Debian. There’s no need to carry this upstream — distributions can add their own packaging as needed. Signed-off-by: Philip Withnall --- README | 3 +- debian/changelog | 5 - debian/compat | 1 - debian/control | 94 ------------------- debian/copyright | 20 ---- debian/docs | 1 - debian/eos-parental-controls-data.install | 4 - debian/eos-parental-controls-tools.install | 2 - debian/gbp.conf | 6 -- debian/gir1.2-eos-parental-controls-0.install | 1 - debian/libeos-parental-controls-0-dev.install | 3 - .../libeos-parental-controls-0-tests.install | 2 - debian/libeos-parental-controls-0.install | 1 - debian/rules | 17 ---- debian/source/format | 1 - debian/tests/control | 4 - debian/tests/gnome-desktop-testing | 27 ------ 17 files changed, 1 insertion(+), 191 deletions(-) delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/docs delete mode 100644 debian/eos-parental-controls-data.install delete mode 100644 debian/eos-parental-controls-tools.install delete mode 100644 debian/gbp.conf delete mode 100644 debian/gir1.2-eos-parental-controls-0.install delete mode 100644 debian/libeos-parental-controls-0-dev.install delete mode 100644 debian/libeos-parental-controls-0-tests.install delete mode 100644 debian/libeos-parental-controls-0.install delete mode 100755 debian/rules delete mode 100644 debian/source/format delete mode 100644 debian/tests/control delete mode 100644 debian/tests/gnome-desktop-testing diff --git a/README b/README index 97aba2c..bb3e87f 100644 --- a/README +++ b/README @@ -24,8 +24,7 @@ Dependencies Licensing ========= -All code in this project is licensed under LGPL-2.1+. See debian/copyright and -COPYING for more details. +All code in this project is licensed under LGPL-2.1+. See COPYING for more details. Bugs ==== diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index 59c5305..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -eos-parental-controls (0) UNRELEASED; urgency=low - - * Initial release (Closes: T23859) - - -- Philip Withnall Fri, 05 Oct 2018 23:36:00 +0100 \ No newline at end of file diff --git a/debian/compat b/debian/compat deleted file mode 100644 index 9a03714..0000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -10 \ No newline at end of file diff --git a/debian/control b/debian/control deleted file mode 100644 index 0298290..0000000 --- a/debian/control +++ /dev/null @@ -1,94 +0,0 @@ -Source: eos-parental-controls -Section: misc -Priority: optional -Maintainer: Philip Withnall -Standards-Version: 4.1.2 -Build-Depends: - debhelper (>= 10), - gir1.2-glib-2.0, - gobject-introspection (>= 1.30.0), - gtk-doc-tools, - libaccountsservice-dev, - libdbus-1-dev, - libgirepository1.0-dev (>= 1.30.0), - libglib2.0-dev (>= 2.54.2), - meson, - policykit-1, - python3-gi, - -Package: eos-parental-controls-data -Section: misc -Architecture: all -Depends: - accountsservice, - policykit-1, - ${misc:Depends}, -Description: Parental Controls - architecture independent files - This package contains the architecture-independent data files. - -Package: eos-parental-controls-tools -Section: misc -Architecture: any -Multi-arch: same -Depends: - eos-parental-controls-data (= ${source:Version}), - gir1.2-eos-parental-controls-0, - gir1.2-glib-2.0, - python3, - python3-gi, - ${misc:Depends}, -Description: Parental Controls Tools - This package contains tools for querying and updating the parental controls - settings for users. - -Package: gir1.2-eos-parental-controls-0 -Section: introspection -Architecture: any -Multi-arch: same -Depends: - ${gir:Depends}, - ${misc:Depends}, -Description: Parental Controls Library - introspection bindings - This package contains a library for accessing the parental controls settings - for users. - . - This package contains a machine-readable API description for - libeos-parental-controls for use by the client tools and other clients. - -Package: libeos-parental-controls-0 -Section: misc -Architecture: any -Depends: - eos-parental-controls-data (= ${source:Version}), - ${misc:Depends}, - ${shlibs:Depends}, -Description: Parental Controls Library - This package contains a library for accessing the parental controls settings - for users. - -Package: libeos-parental-controls-0-dev -Section: libdevel -Architecture: any -Multi-arch: same -Depends: - libglib2.0-dev, - libeos-parental-controls-0 (= ${binary:Version}), - ${misc:Depends}, -Description: Parental Controls Library - library development - This package contains a library for accessing the parental controls settings - for users. - . - This package contains development files for clients. - -Package: libeos-parental-controls-0-tests -Section: misc -Architecture: any -Depends: - ${misc:Depends}, - ${shlibs:Depends}, -Description: Parental Controls Library - tests - This package contains a library for accessing the parental controls settings - for users. - . - This package contains unit tests for the client APIs used to access the - parental controls. \ No newline at end of file diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 509708a..0000000 --- a/debian/copyright +++ /dev/null @@ -1,20 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: eos-parental-controls -Upstream-Contact: Philip Withnall -Source: github.com/endlessm/eos-parental-controls -Disclaimer: Not part of the Debian distribution. -Copyright: Copyright 2018 Endless Mobile, Inc. -License: LGPL-2.1+ - 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 \ No newline at end of file diff --git a/debian/docs b/debian/docs deleted file mode 100644 index 100b938..0000000 --- a/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README \ No newline at end of file diff --git a/debian/eos-parental-controls-data.install b/debian/eos-parental-controls-data.install deleted file mode 100644 index ca3f187..0000000 --- a/debian/eos-parental-controls-data.install +++ /dev/null @@ -1,4 +0,0 @@ -usr/share/accountsservice/interfaces/com.endlessm.ParentalControls.AppFilter.xml -usr/share/dbus-1/interfaces/com.endlessm.ParentalControls.AppFilter.xml -usr/share/polkit-1/actions/com.endlessm.ParentalControls.policy -usr/share/polkit-1/rules.d/com.endlessm.ParentalControls.rules \ No newline at end of file diff --git a/debian/eos-parental-controls-tools.install b/debian/eos-parental-controls-tools.install deleted file mode 100644 index 98f2016..0000000 --- a/debian/eos-parental-controls-tools.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin/eos-parental-controls-client -usr/share/man/man8/eos-parental-controls-client.8* \ No newline at end of file diff --git a/debian/gbp.conf b/debian/gbp.conf deleted file mode 100644 index e309e54..0000000 --- a/debian/gbp.conf +++ /dev/null @@ -1,6 +0,0 @@ -[DEFAULT] -debian-tag = Version_%(version)s -debian-branch = master - -[dch] -ignore-branch = True \ No newline at end of file diff --git a/debian/gir1.2-eos-parental-controls-0.install b/debian/gir1.2-eos-parental-controls-0.install deleted file mode 100644 index 5886c61..0000000 --- a/debian/gir1.2-eos-parental-controls-0.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/girepository-1.0/EosParentalControls-0.* \ No newline at end of file diff --git a/debian/libeos-parental-controls-0-dev.install b/debian/libeos-parental-controls-0-dev.install deleted file mode 100644 index 0cfb211..0000000 --- a/debian/libeos-parental-controls-0-dev.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/include/eos-parental-controls-0 -usr/lib/*/pkgconfig/eos-parental-controls-0.pc -usr/share/gir-1.0/EosParentalControls-0.gir \ No newline at end of file diff --git a/debian/libeos-parental-controls-0-tests.install b/debian/libeos-parental-controls-0-tests.install deleted file mode 100644 index 8a1f430..0000000 --- a/debian/libeos-parental-controls-0-tests.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/lib/*/installed-tests/libeos-parental-controls-0 -usr/share/installed-tests/libeos-parental-controls-0 \ No newline at end of file diff --git a/debian/libeos-parental-controls-0.install b/debian/libeos-parental-controls-0.install deleted file mode 100644 index 17c57b9..0000000 --- a/debian/libeos-parental-controls-0.install +++ /dev/null @@ -1 +0,0 @@ -usr/lib/*/libeos-parental-controls-0.so* \ No newline at end of file diff --git a/debian/rules b/debian/rules deleted file mode 100755 index fa026c7..0000000 --- a/debian/rules +++ /dev/null @@ -1,17 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -export DEB_BUILD_MAINT_OPTIONS = hardening=+all -export LC_ALL=C.UTF-8 - -override_dh_auto_configure: - dh_auto_configure \ - -- \ - -Dinstalled_tests=true \ - $(NULL) - -override_dh_missing: - dh_missing --fail-missing - -%: - dh $@ --with gir --parallel diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 9f67427..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (native) \ No newline at end of file diff --git a/debian/tests/control b/debian/tests/control deleted file mode 100644 index 1849372..0000000 --- a/debian/tests/control +++ /dev/null @@ -1,4 +0,0 @@ -Tests: gnome-desktop-testing -Depends: - gnome-desktop-testing, - libeos-parental-controls-0-tests, \ No newline at end of file diff --git a/debian/tests/gnome-desktop-testing b/debian/tests/gnome-desktop-testing deleted file mode 100644 index f84116f..0000000 --- a/debian/tests/gnome-desktop-testing +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -# Run the eos-parental-controls installed-tests which do not require root -# privileges. - -# Copyright © 2017, 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 - -set -e -exec 2>&1 - -exec gnome-desktop-testing-runner \ - libeos-parental-controls-0 \ - -- \ No newline at end of file From c9889a3ce7f4f420aa96980e22310b713ba97c98 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 26 Feb 2019 17:34:45 +0000 Subject: [PATCH 2/6] docs: Fix homepage link MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We’re now hosted at https://gitlab.freedesktop.org/pwithnall/malcontent. Signed-off-by: Philip Withnall --- README | 2 +- eos-parental-controls.doap | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index bb3e87f..6b7075b 100644 --- a/README +++ b/README @@ -34,4 +34,4 @@ Bug reports and patches should be filed in GitHub. Contact ======= -https://github.com/endlessm/eos-parental-controls +https://gitlab.freedesktop.org/pwithnall/malcontent diff --git a/eos-parental-controls.doap b/eos-parental-controls.doap index 3624c34..2914378 100644 --- a/eos-parental-controls.doap +++ b/eos-parental-controls.doap @@ -2,7 +2,7 @@ eos-parental-controls eos-parental-controls provides restrictions for children on EOS eos-parental-controls implements support for restricting the abilities of non-administrator accounts on an Endless OS system. - + - + From 03436eacf5edcc4c0cc92db207bcaf7d6ab9fc40 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 26 Feb 2019 17:43:56 +0000 Subject: [PATCH 3/6] Rename project from eos-parental-controls to malcontent MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- README | 4 +- eos-parental-controls-client/meson.build | 11 - libeos-parental-controls/meson.build | 62 --- .../app-filter.c | 478 +++++++++--------- .../app-filter.h | 154 +++--- libmalcontent/meson.build | 62 +++ .../tests/accounts-service-iface.h | 0 .../tests/app-filter.c | 414 +++++++-------- .../tests/meson.build | 6 +- .../docs/malcontent-client.8 | 20 +- .../malcontent-client.py | 24 +- malcontent-client/meson.build | 11 + eos-parental-controls.doap => malcontent.doap | 6 +- meson.build | 6 +- po/meson.build | 2 +- 15 files changed, 630 insertions(+), 630 deletions(-) delete mode 100644 eos-parental-controls-client/meson.build delete mode 100644 libeos-parental-controls/meson.build rename {libeos-parental-controls => libmalcontent}/app-filter.c (79%) rename {libeos-parental-controls => libmalcontent}/app-filter.h (55%) create mode 100644 libmalcontent/meson.build rename {libeos-parental-controls => libmalcontent}/tests/accounts-service-iface.h (100%) rename {libeos-parental-controls => libmalcontent}/tests/app-filter.c (77%) rename {libeos-parental-controls => libmalcontent}/tests/meson.build (82%) rename eos-parental-controls-client/docs/eos-parental-controls-client.8 => malcontent-client/docs/malcontent-client.8 (80%) rename eos-parental-controls-client/eos-parental-controls-client.py => malcontent-client/malcontent-client.py (94%) create mode 100644 malcontent-client/meson.build rename eos-parental-controls.doap => malcontent.doap (57%) diff --git a/README b/README index 6b7075b..a500a21 100644 --- a/README +++ b/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 used, a non-administrator account will be for a child using the system; and the administrator accounts will be for the parents. diff --git a/eos-parental-controls-client/meson.build b/eos-parental-controls-client/meson.build deleted file mode 100644 index c06732a..0000000 --- a/eos-parental-controls-client/meson.build +++ /dev/null @@ -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') \ No newline at end of file diff --git a/libeos-parental-controls/meson.build b/libeos-parental-controls/meson.build deleted file mode 100644 index f9b19fd..0000000 --- a/libeos-parental-controls/meson.build +++ /dev/null @@ -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') \ No newline at end of file diff --git a/libeos-parental-controls/app-filter.c b/libmalcontent/app-filter.c similarity index 79% rename from libeos-parental-controls/app-filter.c rename to libmalcontent/app-filter.c index 0b47024..140b628 100644 --- a/libeos-parental-controls/app-filter.c +++ b/libmalcontent/app-filter.c @@ -27,56 +27,56 @@ #include #include #include -#include +#include -G_DEFINE_QUARK (EpcAppFilterError, epc_app_filter_error) +G_DEFINE_QUARK (MctAppFilterError, mct_app_filter_error) /** - * EpcAppFilterListType: - * @EPC_APP_FILTER_LIST_BLACKLIST: Any program in the list is not allowed to + * MctAppFilterListType: + * @MCT_APP_FILTER_LIST_BLACKLIST: Any program in the list is not allowed to * be run. - * @EPC_APP_FILTER_LIST_WHITELIST: Any program not in the list is not allowed + * @MCT_APP_FILTER_LIST_WHITELIST: Any program not in the list is not allowed * to be run. * * Different semantics for interpreting an application list. * - * Since: 0.1.0 + * Since: 0.2.0 */ typedef enum { - EPC_APP_FILTER_LIST_BLACKLIST, - EPC_APP_FILTER_LIST_WHITELIST, -} EpcAppFilterListType; + MCT_APP_FILTER_LIST_BLACKLIST, + MCT_APP_FILTER_LIST_WHITELIST, +} MctAppFilterListType; -struct _EpcAppFilter +struct _MctAppFilter { gint ref_count; uid_t user_id; gchar **app_list; /* (owned) (array zero-terminated=1) */ - EpcAppFilterListType app_list_type; + MctAppFilterListType app_list_type; GVariant *oars_ratings; /* (type a{ss}) (owned non-floating) */ gboolean allow_user_installation; gboolean allow_system_installation; }; -G_DEFINE_BOXED_TYPE (EpcAppFilter, epc_app_filter, - epc_app_filter_ref, epc_app_filter_unref) +G_DEFINE_BOXED_TYPE (MctAppFilter, mct_app_filter, + mct_app_filter_ref, mct_app_filter_unref) /** - * epc_app_filter_ref: - * @filter: (transfer none): an #EpcAppFilter + * mct_app_filter_ref: + * @filter: (transfer none): an #MctAppFilter * * Increment the reference count of @filter, and return the same pointer to it. * * Returns: (transfer full): the same pointer as @filter - * Since: 0.1.0 + * Since: 0.2.0 */ -EpcAppFilter * -epc_app_filter_ref (EpcAppFilter *filter) +MctAppFilter * +mct_app_filter_ref (MctAppFilter *filter) { g_return_val_if_fail (filter != NULL, NULL); g_return_val_if_fail (filter->ref_count >= 1, NULL); @@ -87,16 +87,16 @@ epc_app_filter_ref (EpcAppFilter *filter) } /** - * epc_app_filter_unref: - * @filter: (transfer full): an #EpcAppFilter + * mct_app_filter_unref: + * @filter: (transfer full): an #MctAppFilter * * Decrement the reference count of @filter. If the reference count reaches * zero, free the @filter and all its resources. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_unref (EpcAppFilter *filter) +mct_app_filter_unref (MctAppFilter *filter) { g_return_if_fail (filter != NULL); g_return_if_fail (filter->ref_count >= 1); @@ -112,16 +112,16 @@ epc_app_filter_unref (EpcAppFilter *filter) } /** - * epc_app_filter_get_user_id: - * @filter: an #EpcAppFilter + * mct_app_filter_get_user_id: + * @filter: an #MctAppFilter * - * Get the user ID of the user this #EpcAppFilter is for. + * Get the user ID of the user this #MctAppFilter is for. * * Returns: user ID of the relevant user - * Since: 0.1.0 + * Since: 0.2.0 */ uid_t -epc_app_filter_get_user_id (EpcAppFilter *filter) +mct_app_filter_get_user_id (MctAppFilter *filter) { g_return_val_if_fail (filter != NULL, FALSE); g_return_val_if_fail (filter->ref_count >= 1, FALSE); @@ -130,8 +130,8 @@ epc_app_filter_get_user_id (EpcAppFilter *filter) } /** - * epc_app_filter_is_path_allowed: - * @filter: an #EpcAppFilter + * mct_app_filter_is_path_allowed: + * @filter: an #MctAppFilter * @path: (type filename): absolute path of a program to check * * Check whether the program at @path is allowed to be run according to this @@ -139,10 +139,10 @@ epc_app_filter_get_user_id (EpcAppFilter *filter) * * Returns: %TRUE if the user this @filter corresponds to is allowed to run the * program at @path according to the @filter policy; %FALSE otherwise - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_app_filter_is_path_allowed (EpcAppFilter *filter, +mct_app_filter_is_path_allowed (MctAppFilter *filter, const gchar *path) { g_return_val_if_fail (filter != NULL, FALSE); @@ -156,9 +156,9 @@ epc_app_filter_is_path_allowed (EpcAppFilter *filter, switch (filter->app_list_type) { - case EPC_APP_FILTER_LIST_BLACKLIST: + case MCT_APP_FILTER_LIST_BLACKLIST: return !path_in_list; - case EPC_APP_FILTER_LIST_WHITELIST: + case MCT_APP_FILTER_LIST_WHITELIST: return path_in_list; default: g_assert_not_reached (); @@ -166,8 +166,8 @@ epc_app_filter_is_path_allowed (EpcAppFilter *filter, } /** - * epc_app_filter_is_flatpak_ref_allowed: - * @filter: an #EpcAppFilter + * mct_app_filter_is_flatpak_ref_allowed: + * @filter: an #MctAppFilter * @app_ref: flatpak ref for the app, for example `app/org.gnome.Builder/x86_64/master` * * Check whether the flatpak app with the given @app_ref is allowed to be run @@ -175,10 +175,10 @@ epc_app_filter_is_path_allowed (EpcAppFilter *filter, * * Returns: %TRUE if the user this @filter corresponds to is allowed to run the * flatpak called @app_ref according to the @filter policy; %FALSE otherwise - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_app_filter_is_flatpak_ref_allowed (EpcAppFilter *filter, +mct_app_filter_is_flatpak_ref_allowed (MctAppFilter *filter, const gchar *app_ref) { g_return_val_if_fail (filter != NULL, FALSE); @@ -190,9 +190,9 @@ epc_app_filter_is_flatpak_ref_allowed (EpcAppFilter *filter, switch (filter->app_list_type) { - case EPC_APP_FILTER_LIST_BLACKLIST: + case MCT_APP_FILTER_LIST_BLACKLIST: return !ref_in_list; - case EPC_APP_FILTER_LIST_WHITELIST: + case MCT_APP_FILTER_LIST_WHITELIST: return ref_in_list; default: g_assert_not_reached (); @@ -200,8 +200,8 @@ epc_app_filter_is_flatpak_ref_allowed (EpcAppFilter *filter, } /** - * epc_app_filter_is_flatpak_app_allowed: - * @filter: an #EpcAppFilter + * mct_app_filter_is_flatpak_app_allowed: + * @filter: an #MctAppFilter * @app_id: flatpak ID for the app, for example `org.gnome.Builder` * * Check whether the flatpak app with the given @app_id is allowed to be run @@ -213,10 +213,10 @@ epc_app_filter_is_flatpak_ref_allowed (EpcAppFilter *filter, * * Returns: %TRUE if the user this @filter corresponds to is allowed to run the * flatpak called @app_id according to the @filter policy; %FALSE otherwise - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_app_filter_is_flatpak_app_allowed (EpcAppFilter *filter, +mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter, const gchar *app_id) { g_return_val_if_fail (filter != NULL, FALSE); @@ -241,9 +241,9 @@ epc_app_filter_is_flatpak_app_allowed (EpcAppFilter *filter, switch (filter->app_list_type) { - case EPC_APP_FILTER_LIST_BLACKLIST: + case MCT_APP_FILTER_LIST_BLACKLIST: return !id_in_list; - case EPC_APP_FILTER_LIST_WHITELIST: + case MCT_APP_FILTER_LIST_WHITELIST: return id_in_list; default: g_assert_not_reached (); @@ -251,8 +251,8 @@ epc_app_filter_is_flatpak_app_allowed (EpcAppFilter *filter, } /** - * epc_app_filter_is_appinfo_allowed: - * @filter: an #EpcAppFilter + * mct_app_filter_is_appinfo_allowed: + * @filter: an #MctAppFilter * @app_info: (transfer none): application information * * Check whether the app with the given @app_info is allowed to be run @@ -262,10 +262,10 @@ epc_app_filter_is_flatpak_app_allowed (EpcAppFilter *filter, * Returns: %TRUE if the user this @filter corresponds to is allowed to run the * app represented by @app_info according to the @filter policy; %FALSE * otherwise - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_app_filter_is_appinfo_allowed (EpcAppFilter *filter, +mct_app_filter_is_appinfo_allowed (MctAppFilter *filter, GAppInfo *app_info) { g_autofree gchar *abs_path = NULL; @@ -277,7 +277,7 @@ epc_app_filter_is_appinfo_allowed (EpcAppFilter *filter, abs_path = g_find_program_in_path (g_app_info_get_executable (app_info)); if (abs_path != NULL && - !epc_app_filter_is_path_allowed (filter, abs_path)) + !mct_app_filter_is_path_allowed (filter, abs_path)) return FALSE; if (G_IS_DESKTOP_APP_INFO (app_info)) @@ -291,7 +291,7 @@ epc_app_filter_is_appinfo_allowed (EpcAppFilter *filter, flatpak_app = g_strstrip (flatpak_app); if (flatpak_app != NULL && - !epc_app_filter_is_flatpak_app_allowed (filter, flatpak_app)) + !mct_app_filter_is_flatpak_app_allowed (filter, flatpak_app)) return FALSE; /* FIXME: This could do with the g_desktop_app_info_get_string_list() API @@ -310,7 +310,7 @@ epc_app_filter_is_appinfo_allowed (EpcAppFilter *filter, old_flatpak_app = g_strstrip (old_flatpak_app); if (*old_flatpak_app != '\0' && - !epc_app_filter_is_flatpak_app_allowed (filter, old_flatpak_app)) + !mct_app_filter_is_flatpak_app_allowed (filter, old_flatpak_app)) return FALSE; } } @@ -330,19 +330,19 @@ strcmp_cb (gconstpointer a, } /** - * epc_app_filter_get_oars_sections: - * @filter: an #EpcAppFilter + * mct_app_filter_get_oars_sections: + * @filter: an #MctAppFilter * * List the OARS sections present in this app filter. The sections are returned * in lexicographic order. A section will be listed even if its stored value is - * %EPC_APP_FILTER_OARS_VALUE_UNKNOWN. The returned list may be empty. + * %MCT_APP_FILTER_OARS_VALUE_UNKNOWN. The returned list may be empty. * * Returns: (transfer container) (array zero-terminated=1): %NULL-terminated * array of OARS sections - * Since: 0.1.0 + * Since: 0.2.0 */ const gchar ** -epc_app_filter_get_oars_sections (EpcAppFilter *filter) +mct_app_filter_get_oars_sections (MctAppFilter *filter) { g_autoptr(GPtrArray) sections = g_ptr_array_new_with_free_func (NULL); GVariantIter iter; @@ -365,65 +365,65 @@ epc_app_filter_get_oars_sections (EpcAppFilter *filter) } /** - * epc_app_filter_get_oars_value: - * @filter: an #EpcAppFilter + * mct_app_filter_get_oars_value: + * @filter: an #MctAppFilter * @oars_section: name of the OARS section to get the value from * * Get the value assigned to the given @oars_section in the OARS filter stored * within @filter. If that section has no value explicitly defined, - * %EPC_APP_FILTER_OARS_VALUE_UNKNOWN is returned. + * %MCT_APP_FILTER_OARS_VALUE_UNKNOWN is returned. * * This value is the most intense value allowed for apps to have in this * section, inclusive. Any app with a more intense value for this section must * be hidden from the user whose @filter this is. * - * This does not factor in epc_app_filter_is_system_installation_allowed(). + * This does not factor in mct_app_filter_is_system_installation_allowed(). * - * Returns: an #EpcAppFilterOarsValue - * Since: 0.1.0 + * Returns: an #MctAppFilterOarsValue + * Since: 0.2.0 */ -EpcAppFilterOarsValue -epc_app_filter_get_oars_value (EpcAppFilter *filter, +MctAppFilterOarsValue +mct_app_filter_get_oars_value (MctAppFilter *filter, const gchar *oars_section) { const gchar *value_str; - g_return_val_if_fail (filter != NULL, EPC_APP_FILTER_OARS_VALUE_UNKNOWN); + g_return_val_if_fail (filter != NULL, MCT_APP_FILTER_OARS_VALUE_UNKNOWN); g_return_val_if_fail (filter->ref_count >= 1, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); g_return_val_if_fail (oars_section != NULL && *oars_section != '\0', - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); if (!g_variant_lookup (filter->oars_ratings, oars_section, "&s", &value_str)) - return EPC_APP_FILTER_OARS_VALUE_UNKNOWN; + return MCT_APP_FILTER_OARS_VALUE_UNKNOWN; if (g_str_equal (value_str, "none")) - return EPC_APP_FILTER_OARS_VALUE_NONE; + return MCT_APP_FILTER_OARS_VALUE_NONE; else if (g_str_equal (value_str, "mild")) - return EPC_APP_FILTER_OARS_VALUE_MILD; + return MCT_APP_FILTER_OARS_VALUE_MILD; else if (g_str_equal (value_str, "moderate")) - return EPC_APP_FILTER_OARS_VALUE_MODERATE; + return MCT_APP_FILTER_OARS_VALUE_MODERATE; else if (g_str_equal (value_str, "intense")) - return EPC_APP_FILTER_OARS_VALUE_INTENSE; + return MCT_APP_FILTER_OARS_VALUE_INTENSE; else - return EPC_APP_FILTER_OARS_VALUE_UNKNOWN; + return MCT_APP_FILTER_OARS_VALUE_UNKNOWN; } /** - * epc_app_filter_is_user_installation_allowed: - * @filter: an #EpcAppFilter + * mct_app_filter_is_user_installation_allowed: + * @filter: an #MctAppFilter * * Get whether the user is allowed to install to their flatpak user repository. * This should be queried in addition to the OARS values - * (epc_app_filter_get_oars_value()) — if it returns %FALSE, the OARS values + * (mct_app_filter_get_oars_value()) — if it returns %FALSE, the OARS values * should be ignored and app installation should be unconditionally disallowed. * * Returns: %TRUE if app installation is allowed to the user repository for * this user; %FALSE if it is unconditionally disallowed for this user - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_app_filter_is_user_installation_allowed (EpcAppFilter *filter) +mct_app_filter_is_user_installation_allowed (MctAppFilter *filter) { g_return_val_if_fail (filter != NULL, FALSE); g_return_val_if_fail (filter->ref_count >= 1, FALSE); @@ -432,20 +432,20 @@ epc_app_filter_is_user_installation_allowed (EpcAppFilter *filter) } /** - * epc_app_filter_is_system_installation_allowed: - * @filter: an #EpcAppFilter + * mct_app_filter_is_system_installation_allowed: + * @filter: an #MctAppFilter * * Get whether the user is allowed to install to the flatpak system repository. * This should be queried in addition to the OARS values - * (epc_app_filter_get_oars_value()) — if it returns %FALSE, the OARS values + * (mct_app_filter_get_oars_value()) — if it returns %FALSE, the OARS values * should be ignored and app installation should be unconditionally disallowed. * * Returns: %TRUE if app installation is allowed to the system repository for * this user; %FALSE if it is unconditionally disallowed for this user - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_app_filter_is_system_installation_allowed (EpcAppFilter *filter) +mct_app_filter_is_system_installation_allowed (MctAppFilter *filter) { g_return_val_if_fail (filter != NULL, FALSE); g_return_val_if_fail (filter->ref_count >= 1, FALSE); @@ -454,18 +454,18 @@ epc_app_filter_is_system_installation_allowed (EpcAppFilter *filter) } /** - * _epc_app_filter_build_app_filter_variant: - * @filter: an #EpcAppFilter + * _mct_app_filter_build_app_filter_variant: + * @filter: an #MctAppFilter * * Build a #GVariant which contains the app filter from @filter, in the format * used for storing it in AccountsService. * * Returns: (transfer floating): a new, floating #GVariant containing the app * filter - * Since: 0.1.0 + * Since: 0.2.0 */ static GVariant * -_epc_app_filter_build_app_filter_variant (EpcAppFilter *filter) +_mct_app_filter_build_app_filter_variant (MctAppFilter *filter) { g_auto(GVariantBuilder) builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("(bas)")); @@ -473,7 +473,7 @@ _epc_app_filter_build_app_filter_variant (EpcAppFilter *filter) g_return_val_if_fail (filter->ref_count >= 1, NULL); g_variant_builder_add (&builder, "b", - (filter->app_list_type == EPC_APP_FILTER_LIST_WHITELIST)); + (filter->app_list_type == MCT_APP_FILTER_LIST_WHITELIST)); g_variant_builder_open (&builder, G_VARIANT_TYPE ("as")); for (gsize i = 0; filter->app_list[i] != NULL; i++) @@ -499,19 +499,19 @@ bus_remote_error_matches (const GError *error, return g_str_equal (error_name, expected_error_name); } -/* Convert a #GDBusError into a #EpcAppFilter error. */ +/* Convert a #GDBusError into a #MctAppFilter error. */ static GError * bus_error_to_app_filter_error (const GError *bus_error, uid_t user_id) { if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_ACCESS_DENIED) || bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.PermissionDenied")) - return g_error_new (EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_PERMISSION_DENIED, + return g_error_new (MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_PERMISSION_DENIED, _("Not allowed to query app filter data for user %u"), (guint) user_id); else if (g_error_matches (bus_error, G_DBUS_ERROR, G_DBUS_ERROR_UNKNOWN_METHOD) || bus_remote_error_matches (bus_error, "org.freedesktop.Accounts.Error.Failed")) - return g_error_new (EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_INVALID_USER, + return g_error_new (MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_INVALID_USER, _("User %u does not exist"), (guint) user_id); else return g_error_copy (bus_error); @@ -559,7 +559,7 @@ accounts_find_user_by_id (GDBusConnection *connection, } /** - * epc_get_app_filter: + * mct_get_app_filter: * @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to * use the default * @user_id: ID of the user to query, typically coming from getuid() @@ -568,13 +568,13 @@ accounts_find_user_by_id (GDBusConnection *connection, * @cancellable: (nullable): a #GCancellable, or %NULL * @error: return location for a #GError, or %NULL * - * Synchronous version of epc_get_app_filter_async(). + * Synchronous version of mct_get_app_filter_async(). * * Returns: (transfer full): app filter for the queried user - * Since: 0.1.0 + * Since: 0.2.0 */ -EpcAppFilter * -epc_get_app_filter (GDBusConnection *connection, +MctAppFilter * +mct_get_app_filter (GDBusConnection *connection, uid_t user_id, gboolean allow_interactive_authorization, GCancellable *cancellable, @@ -584,7 +584,7 @@ epc_get_app_filter (GDBusConnection *connection, g_autoptr(GVariant) result_variant = NULL; g_autoptr(GVariant) properties = NULL; g_autoptr(GError) local_error = NULL; - g_autoptr(EpcAppFilter) app_filter = NULL; + g_autoptr(MctAppFilter) app_filter = NULL; gboolean is_whitelist; g_auto(GStrv) app_list = NULL; const gchar *content_rating_kind; @@ -636,8 +636,8 @@ epc_get_app_filter (GDBusConnection *connection, if (!g_variant_lookup (properties, "AppFilter", "(b^as)", &is_whitelist, &app_list)) { - g_set_error (error, EPC_APP_FILTER_ERROR, - EPC_APP_FILTER_ERROR_PERMISSION_DENIED, + g_set_error (error, MCT_APP_FILTER_ERROR, + MCT_APP_FILTER_ERROR_PERMISSION_DENIED, _("Not allowed to query app filter data for user %u"), (guint) user_id); return NULL; @@ -656,8 +656,8 @@ epc_get_app_filter (GDBusConnection *connection, if (!g_str_equal (content_rating_kind, "oars-1.0") && !g_str_equal (content_rating_kind, "oars-1.1")) { - g_set_error (error, EPC_APP_FILTER_ERROR, - EPC_APP_FILTER_ERROR_INVALID_DATA, + g_set_error (error, MCT_APP_FILTER_ERROR, + MCT_APP_FILTER_ERROR_INVALID_DATA, _("OARS filter for user %u has an unrecognized kind ‘%s’"), (guint) user_id, content_rating_kind); return NULL; @@ -677,13 +677,13 @@ epc_get_app_filter (GDBusConnection *connection, allow_system_installation = FALSE; } - /* Success. Create an #EpcAppFilter object to contain the results. */ - app_filter = g_new0 (EpcAppFilter, 1); + /* Success. Create an #MctAppFilter object to contain the results. */ + app_filter = g_new0 (MctAppFilter, 1); app_filter->ref_count = 1; app_filter->user_id = user_id; app_filter->app_list = g_steal_pointer (&app_list); app_filter->app_list_type = - is_whitelist ? EPC_APP_FILTER_LIST_WHITELIST : EPC_APP_FILTER_LIST_BLACKLIST; + is_whitelist ? MCT_APP_FILTER_LIST_WHITELIST : MCT_APP_FILTER_LIST_BLACKLIST; app_filter->oars_ratings = g_steal_pointer (&oars_variant); app_filter->allow_user_installation = allow_user_installation; app_filter->allow_system_installation = allow_system_installation; @@ -713,7 +713,7 @@ get_app_filter_data_free (GetAppFilterData *data) G_DEFINE_AUTOPTR_CLEANUP_FUNC (GetAppFilterData, get_app_filter_data_free) /** - * epc_get_app_filter_async: + * mct_get_app_filter_async: * @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to * use the default * @user_id: ID of the user to query, typically coming from getuid() @@ -730,13 +730,13 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (GetAppFilterData, get_app_filter_data_free) * runs. It’s provided mostly for testing purposes, or to allow an existing * connection to be re-used. Pass %NULL to use the default connection. * - * On failure, an #EpcAppFilterError, a #GDBusError or a #GIOError will be + * On failure, an #MctAppFilterError, a #GDBusError or a #GIOError will be * returned. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_get_app_filter_async (GDBusConnection *connection, +mct_get_app_filter_async (GDBusConnection *connection, uid_t user_id, gboolean allow_interactive_authorization, GCancellable *cancellable, @@ -750,7 +750,7 @@ epc_get_app_filter_async (GDBusConnection *connection, g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); task = g_task_new (NULL, cancellable, callback, user_data); - g_task_set_source_tag (task, epc_get_app_filter_async); + g_task_set_source_tag (task, mct_get_app_filter_async); data = g_new0 (GetAppFilterData, 1); data->connection = (connection != NULL) ? g_object_ref (connection) : NULL; @@ -768,11 +768,11 @@ get_app_filter_thread_cb (GTask *task, gpointer task_data, GCancellable *cancellable) { - g_autoptr(EpcAppFilter) filter = NULL; + g_autoptr(MctAppFilter) filter = NULL; GetAppFilterData *data = task_data; g_autoptr(GError) local_error = NULL; - filter = epc_get_app_filter (data->connection, data->user_id, + filter = mct_get_app_filter (data->connection, data->user_id, data->allow_interactive_authorization, cancellable, &local_error); @@ -780,22 +780,22 @@ get_app_filter_thread_cb (GTask *task, g_task_return_error (task, g_steal_pointer (&local_error)); else g_task_return_pointer (task, g_steal_pointer (&filter), - (GDestroyNotify) epc_app_filter_unref); + (GDestroyNotify) mct_app_filter_unref); } /** - * epc_get_app_filter_finish: + * mct_get_app_filter_finish: * @result: a #GAsyncResult * @error: return location for a #GError, or %NULL * * Finish an asynchronous operation to get the app filter for a user, started - * with epc_get_app_filter_async(). + * with mct_get_app_filter_async(). * * Returns: (transfer full): app filter for the queried user - * Since: 0.1.0 + * Since: 0.2.0 */ -EpcAppFilter * -epc_get_app_filter_finish (GAsyncResult *result, +MctAppFilter * +mct_get_app_filter_finish (GAsyncResult *result, GError **error) { g_return_val_if_fail (g_task_is_valid (result, NULL), NULL); @@ -805,7 +805,7 @@ epc_get_app_filter_finish (GAsyncResult *result, } /** - * epc_set_app_filter: + * mct_set_app_filter: * @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to * use the default * @user_id: ID of the user to set the filter for, typically coming from getuid() @@ -815,15 +815,15 @@ epc_get_app_filter_finish (GAsyncResult *result, * @cancellable: (nullable): a #GCancellable, or %NULL * @error: return location for a #GError, or %NULL * - * Synchronous version of epc_set_app_filter_async(). + * Synchronous version of mct_set_app_filter_async(). * * Returns: %TRUE on success, %FALSE otherwise - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_set_app_filter (GDBusConnection *connection, +mct_set_app_filter (GDBusConnection *connection, uid_t user_id, - EpcAppFilter *app_filter, + MctAppFilter *app_filter, gboolean allow_interactive_authorization, GCancellable *cancellable, GError **error) @@ -856,7 +856,7 @@ epc_set_app_filter (GDBusConnection *connection, if (object_path == NULL) return FALSE; - app_filter_variant = _epc_app_filter_build_app_filter_variant (app_filter); + app_filter_variant = _mct_app_filter_build_app_filter_variant (app_filter); oars_filter_variant = g_variant_new ("(s@a{ss})", "oars-1.1", app_filter->oars_ratings); allow_user_installation_variant = g_variant_new_boolean (app_filter->allow_user_installation); @@ -966,7 +966,7 @@ typedef struct { GDBusConnection *connection; /* (nullable) (owned) */ uid_t user_id; - EpcAppFilter *app_filter; /* (owned) */ + MctAppFilter *app_filter; /* (owned) */ gboolean allow_interactive_authorization; } SetAppFilterData; @@ -974,14 +974,14 @@ static void set_app_filter_data_free (SetAppFilterData *data) { g_clear_object (&data->connection); - epc_app_filter_unref (data->app_filter); + mct_app_filter_unref (data->app_filter); g_free (data); } G_DEFINE_AUTOPTR_CLEANUP_FUNC (SetAppFilterData, set_app_filter_data_free) /** - * epc_set_app_filter_async: + * mct_set_app_filter_async: * @connection: (nullable): a #GDBusConnection to the system bus, or %NULL to * use the default * @user_id: ID of the user to set the filter for, typically coming from getuid() @@ -999,15 +999,15 @@ G_DEFINE_AUTOPTR_CLEANUP_FUNC (SetAppFilterData, set_app_filter_data_free) * runs. It’s provided mostly for testing purposes, or to allow an existing * connection to be re-used. Pass %NULL to use the default connection. * - * On failure, an #EpcAppFilterError, a #GDBusError or a #GIOError will be + * On failure, an #MctAppFilterError, a #GDBusError or a #GIOError will be * returned. The user’s app filter settings will be left in an undefined state. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_set_app_filter_async (GDBusConnection *connection, +mct_set_app_filter_async (GDBusConnection *connection, uid_t user_id, - EpcAppFilter *app_filter, + MctAppFilter *app_filter, gboolean allow_interactive_authorization, GCancellable *cancellable, GAsyncReadyCallback callback, @@ -1022,12 +1022,12 @@ epc_set_app_filter_async (GDBusConnection *connection, g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable)); task = g_task_new (NULL, cancellable, callback, user_data); - g_task_set_source_tag (task, epc_set_app_filter_async); + g_task_set_source_tag (task, mct_set_app_filter_async); data = g_new0 (SetAppFilterData, 1); data->connection = (connection != NULL) ? g_object_ref (connection) : NULL; data->user_id = user_id; - data->app_filter = epc_app_filter_ref (app_filter); + data->app_filter = mct_app_filter_ref (app_filter); data->allow_interactive_authorization = allow_interactive_authorization; g_task_set_task_data (task, g_steal_pointer (&data), (GDestroyNotify) set_app_filter_data_free); @@ -1045,7 +1045,7 @@ set_app_filter_thread_cb (GTask *task, SetAppFilterData *data = task_data; g_autoptr(GError) local_error = NULL; - success = epc_set_app_filter (data->connection, data->user_id, + success = mct_set_app_filter (data->connection, data->user_id, data->app_filter, data->allow_interactive_authorization, cancellable, &local_error); @@ -1057,18 +1057,18 @@ set_app_filter_thread_cb (GTask *task, } /** - * epc_set_app_filter_finish: + * mct_set_app_filter_finish: * @result: a #GAsyncResult * @error: return location for a #GError, or %NULL * * Finish an asynchronous operation to set the app filter for a user, started - * with epc_set_app_filter_async(). + * with mct_set_app_filter_async(). * * Returns: %TRUE on success, %FALSE otherwise - * Since: 0.1.0 + * Since: 0.2.0 */ gboolean -epc_set_app_filter_finish (GAsyncResult *result, +mct_set_app_filter_finish (GAsyncResult *result, GError **error) { g_return_val_if_fail (g_task_is_valid (result, NULL), FALSE); @@ -1078,48 +1078,48 @@ epc_set_app_filter_finish (GAsyncResult *result, } /* - * Actual implementation of #EpcAppFilterBuilder. + * Actual implementation of #MctAppFilterBuilder. * * All members are %NULL if un-initialised, cleared, or ended. */ typedef struct { GPtrArray *paths_blacklist; /* (nullable) (owned) (element-type filename) */ - GHashTable *oars; /* (nullable) (owned) (element-type utf8 EpcAppFilterOarsValue) */ + GHashTable *oars; /* (nullable) (owned) (element-type utf8 MctAppFilterOarsValue) */ gboolean allow_user_installation; gboolean allow_system_installation; /*< private >*/ gpointer padding[2]; -} EpcAppFilterBuilderReal; +} MctAppFilterBuilderReal; -G_STATIC_ASSERT (sizeof (EpcAppFilterBuilderReal) == - sizeof (EpcAppFilterBuilder)); -G_STATIC_ASSERT (__alignof__ (EpcAppFilterBuilderReal) == - __alignof__ (EpcAppFilterBuilder)); +G_STATIC_ASSERT (sizeof (MctAppFilterBuilderReal) == + sizeof (MctAppFilterBuilder)); +G_STATIC_ASSERT (__alignof__ (MctAppFilterBuilderReal) == + __alignof__ (MctAppFilterBuilder)); -G_DEFINE_BOXED_TYPE (EpcAppFilterBuilder, epc_app_filter_builder, - epc_app_filter_builder_copy, epc_app_filter_builder_free) +G_DEFINE_BOXED_TYPE (MctAppFilterBuilder, mct_app_filter_builder, + mct_app_filter_builder_copy, mct_app_filter_builder_free) /** - * epc_app_filter_builder_init: - * @builder: an uninitialised #EpcAppFilterBuilder + * mct_app_filter_builder_init: + * @builder: an uninitialised #MctAppFilterBuilder * * Initialise the given @builder so it can be used to construct a new - * #EpcAppFilter. @builder must have been allocated on the stack, and must not + * #MctAppFilter. @builder must have been allocated on the stack, and must not * already be initialised. * - * Construct the #EpcAppFilter by calling methods on @builder, followed by - * epc_app_filter_builder_end(). To abort construction, use - * epc_app_filter_builder_clear(). + * Construct the #MctAppFilter by calling methods on @builder, followed by + * mct_app_filter_builder_end(). To abort construction, use + * mct_app_filter_builder_clear(). * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_init (EpcAppFilterBuilder *builder) +mct_app_filter_builder_init (MctAppFilterBuilder *builder) { - EpcAppFilterBuilder local_builder = EPC_APP_FILTER_BUILDER_INIT (); - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilder local_builder = MCT_APP_FILTER_BUILDER_INIT (); + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); g_return_if_fail (_builder->paths_blacklist == NULL); @@ -1129,22 +1129,22 @@ epc_app_filter_builder_init (EpcAppFilterBuilder *builder) } /** - * epc_app_filter_builder_clear: - * @builder: an #EpcAppFilterBuilder + * mct_app_filter_builder_clear: + * @builder: an #MctAppFilterBuilder * * Clear @builder, freeing any internal state in it. This will not free the * top-level storage for @builder itself, which is assumed to be allocated on * the stack. * - * If called on an already-cleared #EpcAppFilterBuilder, this function is + * If called on an already-cleared #MctAppFilterBuilder, this function is * idempotent. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_clear (EpcAppFilterBuilder *builder) +mct_app_filter_builder_clear (MctAppFilterBuilder *builder) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); @@ -1153,51 +1153,51 @@ epc_app_filter_builder_clear (EpcAppFilterBuilder *builder) } /** - * epc_app_filter_builder_new: + * mct_app_filter_builder_new: * - * Construct a new #EpcAppFilterBuilder on the heap. This is intended for + * Construct a new #MctAppFilterBuilder on the heap. This is intended for * language bindings. The returned builder must eventually be freed with - * epc_app_filter_builder_free(), but can be cleared zero or more times with - * epc_app_filter_builder_clear() first. + * mct_app_filter_builder_free(), but can be cleared zero or more times with + * mct_app_filter_builder_clear() first. * - * Returns: (transfer full): a new heap-allocated #EpcAppFilterBuilder - * Since: 0.1.0 + * Returns: (transfer full): a new heap-allocated #MctAppFilterBuilder + * Since: 0.2.0 */ -EpcAppFilterBuilder * -epc_app_filter_builder_new (void) +MctAppFilterBuilder * +mct_app_filter_builder_new (void) { - g_autoptr(EpcAppFilterBuilder) builder = NULL; + g_autoptr(MctAppFilterBuilder) builder = NULL; - builder = g_new0 (EpcAppFilterBuilder, 1); - epc_app_filter_builder_init (builder); + builder = g_new0 (MctAppFilterBuilder, 1); + mct_app_filter_builder_init (builder); return g_steal_pointer (&builder); } /** - * epc_app_filter_builder_copy: - * @builder: an #EpcAppFilterBuilder + * mct_app_filter_builder_copy: + * @builder: an #MctAppFilterBuilder * - * Copy the given @builder to a newly-allocated #EpcAppFilterBuilder on the + * Copy the given @builder to a newly-allocated #MctAppFilterBuilder on the * heap. This is safe to use with cleared, stack-allocated - * #EpcAppFilterBuilders. + * #MctAppFilterBuilders. * * Returns: (transfer full): a copy of @builder - * Since: 0.1.0 + * Since: 0.2.0 */ -EpcAppFilterBuilder * -epc_app_filter_builder_copy (EpcAppFilterBuilder *builder) +MctAppFilterBuilder * +mct_app_filter_builder_copy (MctAppFilterBuilder *builder) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; - g_autoptr(EpcAppFilterBuilder) copy = NULL; - EpcAppFilterBuilderReal *_copy; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; + g_autoptr(MctAppFilterBuilder) copy = NULL; + MctAppFilterBuilderReal *_copy; g_return_val_if_fail (builder != NULL, NULL); - copy = epc_app_filter_builder_new (); - _copy = (EpcAppFilterBuilderReal *) copy; + copy = mct_app_filter_builder_new (); + _copy = (MctAppFilterBuilderReal *) copy; - epc_app_filter_builder_clear (copy); + mct_app_filter_builder_clear (copy); if (_builder->paths_blacklist != NULL) _copy->paths_blacklist = g_ptr_array_ref (_builder->paths_blacklist); if (_builder->oars != NULL) @@ -1209,40 +1209,40 @@ epc_app_filter_builder_copy (EpcAppFilterBuilder *builder) } /** - * epc_app_filter_builder_free: - * @builder: a heap-allocated #EpcAppFilterBuilder + * mct_app_filter_builder_free: + * @builder: a heap-allocated #MctAppFilterBuilder * - * Free an #EpcAppFilterBuilder originally allocated using - * epc_app_filter_builder_new(). This must not be called on stack-allocated - * builders initialised using epc_app_filter_builder_init(). + * Free an #MctAppFilterBuilder originally allocated using + * mct_app_filter_builder_new(). This must not be called on stack-allocated + * builders initialised using mct_app_filter_builder_init(). * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_free (EpcAppFilterBuilder *builder) +mct_app_filter_builder_free (MctAppFilterBuilder *builder) { g_return_if_fail (builder != NULL); - epc_app_filter_builder_clear (builder); + mct_app_filter_builder_clear (builder); g_free (builder); } /** - * epc_app_filter_builder_end: - * @builder: an initialised #EpcAppFilterBuilder + * mct_app_filter_builder_end: + * @builder: an initialised #MctAppFilterBuilder * - * Finish constructing an #EpcAppFilter with the given @builder, and return it. - * The #EpcAppFilterBuilder will be cleared as if epc_app_filter_builder_clear() + * Finish constructing an #MctAppFilter with the given @builder, and return it. + * The #MctAppFilterBuilder will be cleared as if mct_app_filter_builder_clear() * had been called. * - * Returns: (transfer full): a newly constructed #EpcAppFilter - * Since: 0.1.0 + * Returns: (transfer full): a newly constructed #MctAppFilter + * Since: 0.2.0 */ -EpcAppFilter * -epc_app_filter_builder_end (EpcAppFilterBuilder *builder) +MctAppFilter * +mct_app_filter_builder_end (MctAppFilterBuilder *builder) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; - g_autoptr(EpcAppFilter) app_filter = NULL; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; + g_autoptr(MctAppFilter) app_filter = NULL; g_auto(GVariantBuilder) oars_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE ("a{ss}")); GHashTableIter iter; gpointer key, value; @@ -1260,10 +1260,10 @@ epc_app_filter_builder_end (EpcAppFilterBuilder *builder) while (g_hash_table_iter_next (&iter, &key, &value)) { const gchar *oars_section = key; - EpcAppFilterOarsValue oars_value = GPOINTER_TO_INT (value); + MctAppFilterOarsValue oars_value = GPOINTER_TO_INT (value); const gchar *oars_value_strs[] = { - NULL, /* EPC_APP_FILTER_OARS_VALUE_UNKNOWN */ + NULL, /* MCT_APP_FILTER_OARS_VALUE_UNKNOWN */ "none", "mild", "moderate", @@ -1280,37 +1280,37 @@ epc_app_filter_builder_end (EpcAppFilterBuilder *builder) oars_variant = g_variant_ref_sink (g_variant_builder_end (&oars_builder)); - /* Build the #EpcAppFilter. */ - app_filter = g_new0 (EpcAppFilter, 1); + /* Build the #MctAppFilter. */ + app_filter = g_new0 (MctAppFilter, 1); app_filter->ref_count = 1; app_filter->user_id = -1; app_filter->app_list = (gchar **) g_ptr_array_free (g_steal_pointer (&_builder->paths_blacklist), FALSE); - app_filter->app_list_type = EPC_APP_FILTER_LIST_BLACKLIST; + app_filter->app_list_type = MCT_APP_FILTER_LIST_BLACKLIST; app_filter->oars_ratings = g_steal_pointer (&oars_variant); app_filter->allow_user_installation = _builder->allow_user_installation; app_filter->allow_system_installation = _builder->allow_system_installation; - epc_app_filter_builder_clear (builder); + mct_app_filter_builder_clear (builder); return g_steal_pointer (&app_filter); } /** - * epc_app_filter_builder_blacklist_path: - * @builder: an initialised #EpcAppFilterBuilder + * mct_app_filter_builder_blacklist_path: + * @builder: an initialised #MctAppFilterBuilder * @path: (type filename): an absolute path to blacklist * * Add @path to the blacklist of app paths in the filter under construction. It * will be canonicalised (without doing any I/O) before being added. * The canonicalised @path will not be added again if it’s already been added. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_blacklist_path (EpcAppFilterBuilder *builder, +mct_app_filter_builder_blacklist_path (MctAppFilterBuilder *builder, const gchar *path) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); g_return_if_fail (_builder->paths_blacklist != NULL); @@ -1325,21 +1325,21 @@ epc_app_filter_builder_blacklist_path (EpcAppFilterBuilder *builder, } /** - * epc_app_filter_builder_blacklist_flatpak_ref: - * @builder: an initialised #EpcAppFilterBuilder + * mct_app_filter_builder_blacklist_flatpak_ref: + * @builder: an initialised #MctAppFilterBuilder * @app_ref: a flatpak app ref to blacklist * * Add @app_ref to the blacklist of flatpak refs in the filter under * construction. The @app_ref will not be added again if it’s already been * added. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_blacklist_flatpak_ref (EpcAppFilterBuilder *builder, +mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder, const gchar *app_ref) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); g_return_if_fail (_builder->paths_blacklist != NULL); @@ -1351,8 +1351,8 @@ epc_app_filter_builder_blacklist_flatpak_ref (EpcAppFilterBuilder *builder, } /** - * epc_app_filter_builder_set_oars_value: - * @builder: an initialised #EpcAppFilterBuilder + * mct_app_filter_builder_set_oars_value: + * @builder: an initialised #MctAppFilterBuilder * @oars_section: name of the OARS section to set the value for * @value: value to set for the @oars_section * @@ -1361,14 +1361,14 @@ epc_app_filter_builder_blacklist_flatpak_ref (EpcAppFilterBuilder *builder, * Any apps which have more intense content in this section should not be usable * by the user. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_set_oars_value (EpcAppFilterBuilder *builder, +mct_app_filter_builder_set_oars_value (MctAppFilterBuilder *builder, const gchar *oars_section, - EpcAppFilterOarsValue value) + MctAppFilterOarsValue value) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); g_return_if_fail (_builder->oars != NULL); @@ -1379,23 +1379,23 @@ epc_app_filter_builder_set_oars_value (EpcAppFilterBuilder *builder, } /** - * epc_app_filter_builder_set_allow_user_installation: - * @builder: an initialised #EpcAppFilterBuilder + * mct_app_filter_builder_set_allow_user_installation: + * @builder: an initialised #MctAppFilterBuilder * @allow_user_installation: %TRUE to allow app installation; %FALSE to * unconditionally disallow it * * Set whether the user is allowed to install to their flatpak user repository. * If this is %TRUE, app installation is still subject to the OARS values - * (epc_app_filter_builder_set_oars_value()). If it is %FALSE, app installation + * (mct_app_filter_builder_set_oars_value()). If it is %FALSE, app installation * is unconditionally disallowed for this user. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_set_allow_user_installation (EpcAppFilterBuilder *builder, +mct_app_filter_builder_set_allow_user_installation (MctAppFilterBuilder *builder, gboolean allow_user_installation) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); @@ -1403,23 +1403,23 @@ epc_app_filter_builder_set_allow_user_installation (EpcAppFilterBuilder *builder } /** - * epc_app_filter_builder_set_allow_system_installation: - * @builder: an initialised #EpcAppFilterBuilder + * mct_app_filter_builder_set_allow_system_installation: + * @builder: an initialised #MctAppFilterBuilder * @allow_system_installation: %TRUE to allow app installation; %FALSE to * unconditionally disallow it * * Set whether the user is allowed to install to the flatpak system repository. * If this is %TRUE, app installation is still subject to the OARS values - * (epc_app_filter_builder_set_oars_value()). If it is %FALSE, app installation + * (mct_app_filter_builder_set_oars_value()). If it is %FALSE, app installation * is unconditionally disallowed for this user. * - * Since: 0.1.0 + * Since: 0.2.0 */ void -epc_app_filter_builder_set_allow_system_installation (EpcAppFilterBuilder *builder, +mct_app_filter_builder_set_allow_system_installation (MctAppFilterBuilder *builder, gboolean allow_system_installation) { - EpcAppFilterBuilderReal *_builder = (EpcAppFilterBuilderReal *) builder; + MctAppFilterBuilderReal *_builder = (MctAppFilterBuilderReal *) builder; g_return_if_fail (_builder != NULL); diff --git a/libeos-parental-controls/app-filter.h b/libmalcontent/app-filter.h similarity index 55% rename from libeos-parental-controls/app-filter.h rename to libmalcontent/app-filter.h index 5cc0a60..67bf8e7 100644 --- a/libeos-parental-controls/app-filter.h +++ b/libmalcontent/app-filter.h @@ -29,57 +29,57 @@ G_BEGIN_DECLS /** - * EpcAppFilterError: - * @EPC_APP_FILTER_ERROR_INVALID_USER: Given user ID doesn’t exist - * @EPC_APP_FILTER_ERROR_PERMISSION_DENIED: Not authorized to query the app + * MctAppFilterError: + * @MCT_APP_FILTER_ERROR_INVALID_USER: Given user ID doesn’t exist + * @MCT_APP_FILTER_ERROR_PERMISSION_DENIED: Not authorized to query the app * 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 * - * 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 { - EPC_APP_FILTER_ERROR_INVALID_USER, - EPC_APP_FILTER_ERROR_PERMISSION_DENIED, - EPC_APP_FILTER_ERROR_INVALID_DATA, -} EpcAppFilterError; + MCT_APP_FILTER_ERROR_INVALID_USER, + MCT_APP_FILTER_ERROR_PERMISSION_DENIED, + MCT_APP_FILTER_ERROR_INVALID_DATA, +} MctAppFilterError; -GQuark epc_app_filter_error_quark (void); -#define EPC_APP_FILTER_ERROR epc_app_filter_error_quark () +GQuark mct_app_filter_error_quark (void); +#define MCT_APP_FILTER_ERROR mct_app_filter_error_quark () /** - * EpcAppFilterOarsValue: - * @EPC_APP_FILTER_OARS_VALUE_UNKNOWN: Unknown value for the given + * MctAppFilterOarsValue: + * @MCT_APP_FILTER_OARS_VALUE_UNKNOWN: Unknown value for the given * section. - * @EPC_APP_FILTER_OARS_VALUE_NONE: No rating for the given section. - * @EPC_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_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. - * @EPC_APP_FILTER_OARS_VALUE_INTENSE: Intense rating for the given + * @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.1.0 + * Since: 0.2.0 */ typedef enum { - EPC_APP_FILTER_OARS_VALUE_UNKNOWN, - EPC_APP_FILTER_OARS_VALUE_NONE, - EPC_APP_FILTER_OARS_VALUE_MILD, - EPC_APP_FILTER_OARS_VALUE_MODERATE, - EPC_APP_FILTER_OARS_VALUE_INTENSE, -} EpcAppFilterOarsValue; + 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; /** - * 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 * 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 * polkit. * - * Since: 0.1.0 + * Since: 0.2.0 */ -typedef struct _EpcAppFilter EpcAppFilter; -GType epc_app_filter_get_type (void); +typedef struct _MctAppFilter MctAppFilter; +GType mct_app_filter_get_type (void); -EpcAppFilter *epc_app_filter_ref (EpcAppFilter *filter); -void epc_app_filter_unref (EpcAppFilter *filter); +MctAppFilter *mct_app_filter_ref (MctAppFilter *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); -gboolean epc_app_filter_is_path_allowed (EpcAppFilter *filter, +uid_t mct_app_filter_get_user_id (MctAppFilter *filter); +gboolean mct_app_filter_is_path_allowed (MctAppFilter *filter, 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); -gboolean epc_app_filter_is_flatpak_app_allowed (EpcAppFilter *filter, +gboolean mct_app_filter_is_flatpak_app_allowed (MctAppFilter *filter, 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); -const gchar **epc_app_filter_get_oars_sections (EpcAppFilter *filter); -EpcAppFilterOarsValue epc_app_filter_get_oars_value (EpcAppFilter *filter, +const gchar **mct_app_filter_get_oars_sections (MctAppFilter *filter); +MctAppFilterOarsValue mct_app_filter_get_oars_value (MctAppFilter *filter, const gchar *oars_section); -gboolean epc_app_filter_is_user_installation_allowed (EpcAppFilter *filter); -gboolean epc_app_filter_is_system_installation_allowed (EpcAppFilter *filter); +gboolean mct_app_filter_is_user_installation_allowed (MctAppFilter *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, gboolean allow_interactive_authorization, GCancellable *cancellable, GError **error); -void epc_get_app_filter_async (GDBusConnection *connection, +void mct_get_app_filter_async (GDBusConnection *connection, uid_t user_id, gboolean allow_interactive_authorization, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); -EpcAppFilter *epc_get_app_filter_finish (GAsyncResult *result, +MctAppFilter *mct_get_app_filter_finish (GAsyncResult *result, GError **error); -gboolean epc_set_app_filter (GDBusConnection *connection, +gboolean mct_set_app_filter (GDBusConnection *connection, uid_t user_id, - EpcAppFilter *app_filter, + MctAppFilter *app_filter, gboolean allow_interactive_authorization, GCancellable *cancellable, GError **error); -void epc_set_app_filter_async (GDBusConnection *connection, +void mct_set_app_filter_async (GDBusConnection *connection, uid_t user_id, - EpcAppFilter *app_filter, + MctAppFilter *app_filter, gboolean allow_interactive_authorization, GCancellable *cancellable, GAsyncReadyCallback callback, gpointer user_data); -gboolean epc_set_app_filter_finish (GAsyncResult *result, +gboolean mct_set_app_filter_finish (GAsyncResult *result, GError **error); /** - * EpcAppFilterBuilder: + * MctAppFilterBuilder: * - * #EpcAppFilterBuilder is a stack-allocated mutable structure used to build an - * #EpcAppFilter instance. Use epc_app_filter_builder_init(), various method + * #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 - * 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 { @@ -163,24 +163,24 @@ typedef struct gboolean b1; gpointer p2; 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. * * 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_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, \ } -void epc_app_filter_builder_init (EpcAppFilterBuilder *builder); -void epc_app_filter_builder_clear (EpcAppFilterBuilder *builder); +void mct_app_filter_builder_init (MctAppFilterBuilder *builder); +void mct_app_filter_builder_clear (MctAppFilterBuilder *builder); -G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (EpcAppFilterBuilder, - epc_app_filter_builder_clear) +G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC (MctAppFilterBuilder, + mct_app_filter_builder_clear) -EpcAppFilterBuilder *epc_app_filter_builder_new (void); -EpcAppFilterBuilder *epc_app_filter_builder_copy (EpcAppFilterBuilder *builder); -void epc_app_filter_builder_free (EpcAppFilterBuilder *builder); +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 (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); -void epc_app_filter_builder_blacklist_flatpak_ref (EpcAppFilterBuilder *builder, +void mct_app_filter_builder_blacklist_flatpak_ref (MctAppFilterBuilder *builder, 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, - 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); -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); G_END_DECLS diff --git a/libmalcontent/meson.build b/libmalcontent/meson.build new file mode 100644 index 0000000..ea10b25 --- /dev/null +++ b/libmalcontent/meson.build @@ -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') \ No newline at end of file diff --git a/libeos-parental-controls/tests/accounts-service-iface.h b/libmalcontent/tests/accounts-service-iface.h similarity index 100% rename from libeos-parental-controls/tests/accounts-service-iface.h rename to libmalcontent/tests/accounts-service-iface.h diff --git a/libeos-parental-controls/tests/app-filter.c b/libmalcontent/tests/app-filter.c similarity index 77% rename from libeos-parental-controls/tests/app-filter.c rename to libmalcontent/tests/app-filter.c index 6f40811..a4ff981 100644 --- a/libeos-parental-controls/tests/app-filter.c +++ b/libmalcontent/tests/app-filter.c @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -71,53 +71,53 @@ assert_strv_equal (const gchar * const *strv_a, static 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. */ static void test_app_filter_types (void) { - g_type_ensure (epc_app_filter_get_type ()); - g_type_ensure (epc_app_filter_builder_get_type ()); + g_type_ensure (mct_app_filter_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 test_app_filter_refs (void) { - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) filter = NULL; - /* Use an empty #EpcAppFilter. */ - filter = epc_app_filter_builder_end (&builder); + /* Use an empty #MctAppFilter. */ + filter = mct_app_filter_builder_end (&builder); g_assert_nonnull (filter); /* 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")); - epc_app_filter_ref (filter); - g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false")); - epc_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")); + mct_app_filter_ref (filter); + g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false")); + mct_app_filter_unref (filter); + g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false")); /* 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. */ typedef struct { - EpcAppFilterBuilder *builder; - EpcAppFilterBuilder stack_builder; + MctAppFilterBuilder *builder; + MctAppFilterBuilder stack_builder; } BuilderFixture; static void builder_set_up_stack (BuilderFixture *fixture, gconstpointer test_data) { - epc_app_filter_builder_init (&fixture->stack_builder); + mct_app_filter_builder_init (&fixture->stack_builder); fixture->builder = &fixture->stack_builder; } @@ -125,7 +125,7 @@ static void builder_tear_down_stack (BuilderFixture *fixture, gconstpointer test_data) { - epc_app_filter_builder_clear (&fixture->stack_builder); + mct_app_filter_builder_clear (&fixture->stack_builder); fixture->builder = NULL; } @@ -133,7 +133,7 @@ static void builder_set_up_stack2 (BuilderFixture *fixture, 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)); fixture->builder = &fixture->stack_builder; } @@ -142,7 +142,7 @@ static void builder_tear_down_stack2 (BuilderFixture *fixture, gconstpointer test_data) { - epc_app_filter_builder_clear (&fixture->stack_builder); + mct_app_filter_builder_clear (&fixture->stack_builder); fixture->builder = NULL; } @@ -150,152 +150,152 @@ static void builder_set_up_heap (BuilderFixture *fixture, gconstpointer test_data) { - fixture->builder = epc_app_filter_builder_new (); + fixture->builder = mct_app_filter_builder_new (); } static void builder_tear_down_heap (BuilderFixture *fixture, 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 test_app_filter_builder_non_empty (BuilderFixture *fixture, gconstpointer test_data) { - g_autoptr(EpcAppFilter) filter = NULL; + g_autoptr(MctAppFilter) filter = NULL; g_autofree const gchar **sections = NULL; - epc_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, "/bin/true"); + 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"); - epc_app_filter_builder_set_oars_value (fixture->builder, "drugs-alcohol", - EPC_APP_FILTER_OARS_VALUE_MILD); - epc_app_filter_builder_set_oars_value (fixture->builder, "language-humor", - EPC_APP_FILTER_OARS_VALUE_MODERATE); - epc_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_oars_value (fixture->builder, "drugs-alcohol", + MCT_APP_FILTER_OARS_VALUE_MILD); + mct_app_filter_builder_set_oars_value (fixture->builder, "language-humor", + MCT_APP_FILTER_OARS_VALUE_MODERATE); + mct_app_filter_builder_set_allow_user_installation (fixture->builder, TRUE); + 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_false (epc_app_filter_is_path_allowed (filter, + g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false")); + g_assert_false (mct_app_filter_is_path_allowed (filter, "/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")); - g_assert_true (epc_app_filter_is_flatpak_app_allowed (filter, "org.gnome.Ponies")); - g_assert_false (epc_app_filter_is_flatpak_ref_allowed (filter, + g_assert_true (mct_app_filter_is_flatpak_app_allowed (filter, "org.gnome.Ponies")); + g_assert_false (mct_app_filter_is_flatpak_ref_allowed (filter, "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"), ==, - EPC_APP_FILTER_OARS_VALUE_MILD); - g_assert_cmpint (epc_app_filter_get_oars_value (filter, "language-humor"), ==, - EPC_APP_FILTER_OARS_VALUE_MODERATE); - g_assert_cmpint (epc_app_filter_get_oars_value (filter, "something-else"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_cmpint (mct_app_filter_get_oars_value (filter, "drugs-alcohol"), ==, + MCT_APP_FILTER_OARS_VALUE_MILD); + g_assert_cmpint (mct_app_filter_get_oars_value (filter, "language-humor"), ==, + MCT_APP_FILTER_OARS_VALUE_MODERATE); + g_assert_cmpint (mct_app_filter_get_oars_value (filter, "something-else"), ==, + 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 }; assert_strv_equal ((const gchar * const *) sections, expected_sections); - g_assert_true (epc_app_filter_is_user_installation_allowed (filter)); - g_assert_false (epc_app_filter_is_system_installation_allowed (filter)); + g_assert_true (mct_app_filter_is_user_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 test_app_filter_builder_empty (BuilderFixture *fixture, gconstpointer test_data) { - g_autoptr(EpcAppFilter) filter = NULL; + g_autoptr(MctAppFilter) filter = 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 (epc_app_filter_is_path_allowed (filter, + g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false")); + g_assert_true (mct_app_filter_is_path_allowed (filter, "/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")); - g_assert_true (epc_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_app_allowed (filter, "org.gnome.Ponies")); + g_assert_true (mct_app_filter_is_flatpak_ref_allowed (filter, "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"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); - g_assert_cmpint (epc_app_filter_get_oars_value (filter, "language-humor"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); - g_assert_cmpint (epc_app_filter_get_oars_value (filter, "something-else"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_cmpint (mct_app_filter_get_oars_value (filter, "drugs-alcohol"), ==, + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_cmpint (mct_app_filter_get_oars_value (filter, "language-humor"), ==, + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_cmpint (mct_app_filter_get_oars_value (filter, "something-else"), ==, + 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 }; assert_strv_equal ((const gchar * const *) sections, expected_sections); - g_assert_true (epc_app_filter_is_user_installation_allowed (filter)); - g_assert_false (epc_app_filter_is_system_installation_allowed (filter)); + g_assert_true (mct_app_filter_is_user_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. */ static void test_app_filter_builder_copy_empty (void) { - g_autoptr(EpcAppFilterBuilder) builder = epc_app_filter_builder_new (); - g_autoptr(EpcAppFilterBuilder) builder_copy = NULL; - g_autoptr(EpcAppFilter) filter = NULL; + g_autoptr(MctAppFilterBuilder) builder = mct_app_filter_builder_new (); + g_autoptr(MctAppFilterBuilder) builder_copy = NULL; + g_autoptr(MctAppFilter) filter = NULL; - epc_app_filter_builder_clear (builder); - builder_copy = epc_app_filter_builder_copy (builder); + mct_app_filter_builder_clear (builder); + builder_copy = mct_app_filter_builder_copy (builder); - epc_app_filter_builder_init (builder_copy); - epc_app_filter_builder_blacklist_path (builder_copy, "/bin/true"); - filter = epc_app_filter_builder_end (builder_copy); + mct_app_filter_builder_init (builder_copy); + mct_app_filter_builder_blacklist_path (builder_copy, "/bin/true"); + filter = mct_app_filter_builder_end (builder_copy); - g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false")); - g_assert_false (epc_app_filter_is_path_allowed (filter, "/bin/true")); + g_assert_true (mct_app_filter_is_path_allowed (filter, "/bin/false")); + 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_false (epc_app_filter_is_system_installation_allowed (filter)); + g_assert_true (mct_app_filter_is_user_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. */ static void test_app_filter_builder_copy_full (void) { - g_autoptr(EpcAppFilterBuilder) builder = epc_app_filter_builder_new (); - g_autoptr(EpcAppFilterBuilder) builder_copy = NULL; - g_autoptr(EpcAppFilter) filter = NULL; + g_autoptr(MctAppFilterBuilder) builder = mct_app_filter_builder_new (); + g_autoptr(MctAppFilterBuilder) builder_copy = NULL; + g_autoptr(MctAppFilter) filter = NULL; - epc_app_filter_builder_blacklist_path (builder, "/bin/true"); - epc_app_filter_builder_set_allow_user_installation (builder, FALSE); - epc_app_filter_builder_set_allow_system_installation (builder, TRUE); - builder_copy = epc_app_filter_builder_copy (builder); - filter = epc_app_filter_builder_end (builder_copy); + mct_app_filter_builder_blacklist_path (builder, "/bin/true"); + mct_app_filter_builder_set_allow_user_installation (builder, FALSE); + mct_app_filter_builder_set_allow_system_installation (builder, TRUE); + builder_copy = mct_app_filter_builder_copy (builder); + filter = mct_app_filter_builder_end (builder_copy); - g_assert_true (epc_app_filter_is_path_allowed (filter, "/bin/false")); - g_assert_false (epc_app_filter_is_path_allowed (filter, "/bin/true")); - g_assert_false (epc_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_path_allowed (filter, "/bin/false")); + g_assert_false (mct_app_filter_is_path_allowed (filter, "/bin/true")); + g_assert_false (mct_app_filter_is_user_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 - * as appropriate by epc_app_filter_is_appinfo_allowed(). */ + * as appropriate by mct_app_filter_is_appinfo_allowed(). */ static void test_app_filter_appinfo (void) { - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) filter = NULL; const struct { gboolean expected_allowed; @@ -379,10 +379,10 @@ test_app_filter_appinfo (void) "X-Flatpak-RenamedFrom=org.gnome.Nasty.desktop;\n" }, }; - epc_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_path (&builder, "/bin/false"); + 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++) { @@ -402,9 +402,9 @@ test_app_filter_appinfo (void) g_assert_nonnull (appinfo); 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 - 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 * given in #GetAppFilterData.properties if queried for a UID matching * #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 { uid_t expected_uid; @@ -522,7 +522,7 @@ get_app_filter_server_cb (GtDBusQueue *queue, 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 * synchronously (%FALSE) or asynchronously (%TRUE). * @@ -532,7 +532,7 @@ static void test_app_filter_bus_get (BusFixture *fixture, gconstpointer test_data) { - g_autoptr(EpcAppFilter) app_filter = NULL; + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; gboolean test_async = GPOINTER_TO_UINT (test_data); const GetAppFilterData get_app_filter_data = @@ -553,17 +553,17 @@ test_app_filter_bus_get (BusFixture *fixture, { 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, FALSE, NULL, async_result_cb, &result); while (result == NULL) 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 { - 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, FALSE, NULL, &local_error); } @@ -572,13 +572,13 @@ test_app_filter_bus_get (BusFixture *fixture, g_assert_nonnull (app_filter); /* Check the app filter properties. */ - g_assert_cmpuint (epc_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_true (epc_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Chess")); + g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid); + g_assert_false (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder")); + 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 - * service works, and that the #EpcAppFilter methods handle the whitelist +/* Test that getting an #MctAppFilter containing a whitelist from the mock D-Bus + * service works, and that the #MctAppFilter methods handle the whitelist * correctly. * * 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, gconstpointer test_data) { - g_autoptr(EpcAppFilter) app_filter = NULL; + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; 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, (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, 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, * whereas typically a blacklist is returned. */ - g_assert_cmpuint (epc_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_true (epc_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 (epc_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_true (epc_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_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid); + g_assert_false (mct_app_filter_is_flatpak_app_allowed (app_filter, "org.gnome.Builder")); + g_assert_true (mct_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.Whitelisted2")); + g_assert_true (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/stable")); + g_assert_false (mct_app_filter_is_flatpak_ref_allowed (app_filter, "app/org.gnome.Whitelisted1/x86_64/unknown")); + g_assert_true (mct_app_filter_is_path_allowed (app_filter, "/usr/bin/true")); + 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 - * the mock D-Bus service works, and that the #EpcAppFilter methods handle them +/* Test that getting an #MctAppFilter containing all possible OARS values from + * the mock D-Bus service works, and that the #MctAppFilter methods handle them * correctly. * * 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, gconstpointer test_data) { - g_autoptr(EpcAppFilter) app_filter = NULL; + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; 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, (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, 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 * correctly, except for the unknown `other` one. */ - g_assert_cmpuint (epc_app_filter_get_user_id (app_filter), ==, fixture->valid_uid); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==, - EPC_APP_FILTER_OARS_VALUE_NONE); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-sexual"), ==, - EPC_APP_FILTER_OARS_VALUE_MILD); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-fantasy"), ==, - EPC_APP_FILTER_OARS_VALUE_MODERATE); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-realistic"), ==, - EPC_APP_FILTER_OARS_VALUE_INTENSE); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "language-profanity"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "unlisted-category"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==, + MCT_APP_FILTER_OARS_VALUE_NONE); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-sexual"), ==, + MCT_APP_FILTER_OARS_VALUE_MILD); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-fantasy"), ==, + MCT_APP_FILTER_OARS_VALUE_MODERATE); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-realistic"), ==, + MCT_APP_FILTER_OARS_VALUE_INTENSE); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "language-profanity"), ==, + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "unlisted-category"), ==, + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); } -/* Test that getting an #EpcAppFilter containing only an `AppFilter` property - * from the mock D-Bus service works, and that the #EpcAppFilter methods use +/* Test that getting an #MctAppFilter containing only an `AppFilter` property + * from the mock D-Bus service works, and that the #MctAppFilter methods use * appropriate defaults. * * 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, gconstpointer test_data) { - g_autoptr(EpcAppFilter) app_filter = NULL; + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; 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, (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, FALSE, NULL, &local_error); @@ -711,16 +711,16 @@ test_app_filter_bus_get_defaults (BusFixture *fixture, g_assert_nonnull (app_filter); /* Check the default values for the properties. */ - g_assert_cmpuint (epc_app_filter_get_user_id (app_filter), ==, fixture->valid_uid); - oars_sections = epc_app_filter_get_oars_sections (app_filter); + g_assert_cmpuint (mct_app_filter_get_user_id (app_filter), ==, fixture->valid_uid); + oars_sections = mct_app_filter_get_oars_sections (app_filter); g_assert_cmpuint (g_strv_length ((gchar **) oars_sections), ==, 0); - g_assert_cmpint (epc_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==, - EPC_APP_FILTER_OARS_VALUE_UNKNOWN); - g_assert_true (epc_app_filter_is_user_installation_allowed (app_filter)); - g_assert_false (epc_app_filter_is_system_installation_allowed (app_filter)); + g_assert_cmpint (mct_app_filter_get_oars_value (app_filter, "violence-bloodshed"), ==, + MCT_APP_FILTER_OARS_VALUE_UNKNOWN); + g_assert_true (mct_app_filter_is_user_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. * * 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(GDBusMethodInvocation) invocation = 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, 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. */ while (result == NULL) 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, - 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); } -/* 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 * to permissions. * @@ -776,9 +776,9 @@ test_app_filter_bus_get_error_permission_denied (BusFixture *fixture, g_autoptr(GDBusMethodInvocation) invocation1 = NULL; g_autoptr(GDBusMethodInvocation) invocation2 = 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, 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. */ while (result == NULL) 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, - 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); } -/* 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 * 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) invocation2 = 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, 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. */ while (result == NULL) 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, - 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); } -/* 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. * * 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(GError) local_error = 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, 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, "org.freedesktop.Accounts.Error.NewAndInterestingError", "This is a fake error message " - "which libeos-parental-controls " + "which libmalcontent " "will never have seen before, " "but must still handle correctly"); /* Get the get_app_filter() result. */ while (result == NULL) 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. */ 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 * synchronously (%FALSE) or asynchronously (%TRUE). * @@ -1034,8 +1034,8 @@ test_app_filter_bus_set (BusFixture *fixture, gconstpointer test_data) { gboolean success; - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) app_filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; gboolean test_async = GPOINTER_TO_UINT (test_data); const SetAppFilterData set_app_filter_data = @@ -1049,14 +1049,14 @@ test_app_filter_bus_set (BusFixture *fixture, }; /* Build an app filter. */ - epc_app_filter_builder_blacklist_path (&builder, "/usr/bin/false"); - epc_app_filter_builder_blacklist_path (&builder, "/usr/bin/banned"); - epc_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); - epc_app_filter_builder_set_allow_user_installation (&builder, TRUE); - epc_app_filter_builder_set_allow_system_installation (&builder, TRUE); + mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/false"); + mct_app_filter_builder_blacklist_path (&builder, "/usr/bin/banned"); + mct_app_filter_builder_blacklist_flatpak_ref (&builder, "app/org.gnome.Nasty/x86_64/stable"); + mct_app_filter_builder_set_oars_value (&builder, "violence-fantasy", MCT_APP_FILTER_OARS_VALUE_INTENSE); + mct_app_filter_builder_set_allow_user_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. */ 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; - 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, FALSE, NULL, async_result_cb, &result); while (result == NULL) 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 { - 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, FALSE, NULL, &local_error); } @@ -1085,7 +1085,7 @@ test_app_filter_bus_set (BusFixture *fixture, 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. * * 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) { gboolean success; - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) app_filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GAsyncResult) result = NULL; g_autoptr(GError) local_error = NULL; g_autoptr(GDBusMethodInvocation) invocation = NULL; g_autofree gchar *error_message = NULL; /* 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, 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. */ while (result == NULL) 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, - EPC_APP_FILTER_ERROR, EPC_APP_FILTER_ERROR_INVALID_USER); + MCT_APP_FILTER_ERROR, MCT_APP_FILTER_ERROR_INVALID_USER); 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. * * 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) { gboolean success; - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) app_filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; 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. */ - 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, (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, FALSE, NULL, &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); } -/* 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. * * 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) { gboolean success; - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) app_filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; const SetAppFilterData set_app_filter_data = { @@ -1185,17 +1185,17 @@ test_app_filter_bus_set_error_unknown (BusFixture *fixture, .error_index = 0, .dbus_error_name = "org.freedesktop.Accounts.Error.NewAndInterestingError", .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", }; /* 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, (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, FALSE, NULL, &local_error); @@ -1203,7 +1203,7 @@ test_app_filter_bus_set_error_unknown (BusFixture *fixture, 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. * * @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) { gboolean success; - g_auto(EpcAppFilterBuilder) builder = EPC_APP_FILTER_BUILDER_INIT (); - g_autoptr(EpcAppFilter) app_filter = NULL; + g_auto(MctAppFilterBuilder) builder = MCT_APP_FILTER_BUILDER_INIT (); + g_autoptr(MctAppFilter) app_filter = NULL; g_autoptr(GError) local_error = NULL; 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. */ - 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, (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, FALSE, NULL, &local_error); diff --git a/libeos-parental-controls/tests/meson.build b/libmalcontent/tests/meson.build similarity index 82% rename from libeos-parental-controls/tests/meson.build rename to libmalcontent/tests/meson.build index 3b8eede..a139da6 100644 --- a/libeos-parental-controls/tests/meson.build +++ b/libmalcontent/tests/meson.build @@ -3,7 +3,7 @@ deps = [ dependency('gio-unix-2.0', version: '>= 2.44'), dependency('glib-2.0', version: '>= 2.54.2'), dependency('gobject-2.0', version: '>= 2.44'), - libeos_parental_controls_dep, + libmalcontent_dep, libglib_testing_dep, ] @@ -17,9 +17,9 @@ test_programs = [ ] 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', - 'libeos-parental-controls-' + libeos_parental_controls_api_version) + 'libmalcontent-' + libmalcontent_api_version) foreach program: test_programs test_conf = configuration_data() diff --git a/eos-parental-controls-client/docs/eos-parental-controls-client.8 b/malcontent-client/docs/malcontent-client.8 similarity index 80% rename from eos-parental-controls-client/docs/eos-parental-controls-client.8 rename to malcontent-client/docs/malcontent-client.8 index 99910b5..041d243 100644 --- a/eos-parental-controls-client/docs/eos-parental-controls-client.8 +++ b/malcontent-client/docs/malcontent-client.8 @@ -1,23 +1,23 @@ -.\" Manpage for eos\-parental\-controls\-client. -.\" Documentation is under the same licence as the eos\-parental\-controls +.\" Manpage for malcontent\-client. +.\" Documentation is under the same licence as the malcontent .\" 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 .IX Header "NAME" -eos\-parental\-controls\-client — Parental Controls Access Utility +malcontent\-client — Parental Controls Access Utility .\" .SH SYNOPSIS .IX Header "SYNOPSIS" .\" -\fBeos\-parental\-controls\-client get [\-q] [\-n] [\fPUSER\fB] +\fBmalcontent\-client get [\-q] [\-n] [\fPUSER\fB] .PP -\fBeos\-parental\-controls\-client check [\-q] [\-n] [\fPUSER\fB] \fPPATH\fB +\fBmalcontent\-client check [\-q] [\-n] [\fPUSER\fB] \fPPATH\fB .\" .SH 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 adminstrator access to do anything more than query the current user’s parental controls. @@ -66,7 +66,7 @@ authorization.) .SH "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 production: .\" @@ -79,7 +79,7 @@ debug output to be enabled. .SH "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. .\" .IP "0" 4 @@ -90,7 +90,7 @@ given user. .\" .IP "1" 4 .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. .\" .IP "2" 4 diff --git a/eos-parental-controls-client/eos-parental-controls-client.py b/malcontent-client/malcontent-client.py similarity index 94% rename from eos-parental-controls-client/eos-parental-controls-client.py rename to malcontent-client/malcontent-client.py index fc3d238..ebbf5c2 100644 --- a/eos-parental-controls-client/eos-parental-controls-client.py +++ b/malcontent-client/malcontent-client.py @@ -21,8 +21,8 @@ import os import pwd import sys import gi -gi.require_version('EosParentalControls', '0') # noqa -from gi.repository import EosParentalControls, GLib +gi.require_version('Malcontent', '0') # noqa +from gi.repository import Malcontent, GLib # 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 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, 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 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, allow_interactive_authorization=interactive, cancellable=None) @@ -98,16 +98,16 @@ def __lookup_user_id_or_error(user): oars_value_mapping = { - EosParentalControls.AppFilterOarsValue.UNKNOWN: "unknown", - EosParentalControls.AppFilterOarsValue.NONE: "none", - EosParentalControls.AppFilterOarsValue.MILD: "mild", - EosParentalControls.AppFilterOarsValue.MODERATE: "moderate", - EosParentalControls.AppFilterOarsValue.INTENSE: "intense", + Malcontent.AppFilterOarsValue.UNKNOWN: "unknown", + Malcontent.AppFilterOarsValue.NONE: "none", + Malcontent.AppFilterOarsValue.MILD: "mild", + Malcontent.AppFilterOarsValue.MODERATE: "moderate", + Malcontent.AppFilterOarsValue.INTENSE: "intense", } def __oars_value_to_string(value): - """Convert an EosParentalControls.AppFilterOarsValue to a human-readable + """Convert an Malcontent.AppFilterOarsValue to a human-readable string.""" try: return oars_value_mapping[value] @@ -117,7 +117,7 @@ def __oars_value_to_string(value): def __oars_value_from_string(value_str): """Convert a human-readable string to an - EosParentalControls.AppFilterOarsValue.""" + Malcontent.AppFilterOarsValue.""" for k, v in oars_value_mapping.items(): if v == value_str: return k @@ -196,7 +196,7 @@ def command_set(user, allow_user_installation=True, quiet=False, interactive=True): """Set the app filter for the given 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_system_installation(allow_system_installation) diff --git a/malcontent-client/meson.build b/malcontent-client/meson.build new file mode 100644 index 0000000..beb7060 --- /dev/null +++ b/malcontent-client/meson.build @@ -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') \ No newline at end of file diff --git a/eos-parental-controls.doap b/malcontent.doap similarity index 57% rename from eos-parental-controls.doap rename to malcontent.doap index 2914378..7a8e2f6 100644 --- a/eos-parental-controls.doap +++ b/malcontent.doap @@ -1,7 +1,7 @@ - eos-parental-controls - eos-parental-controls provides restrictions for children on EOS - eos-parental-controls implements support for restricting the abilities of non-administrator accounts on an Endless OS system. + malcontent + malcontent provides restrictions for children on EOS + malcontent implements support for restricting the abilities of non-administrator accounts on an Endless OS system. diff --git a/meson.build b/meson.build index ee8667e..bab2991 100644 --- a/meson.build +++ b/meson.build @@ -1,4 +1,4 @@ -project('eos-parental-controls', 'c', +project('malcontent', 'c', version : '0.1.0', meson_version : '>= 0.47.0', license: 'LGPLv2.1+', @@ -119,5 +119,5 @@ test_env = [ ] subdir('accounts-service') -subdir('eos-parental-controls-client') -subdir('libeos-parental-controls') \ No newline at end of file +subdir('malcontent-client') +subdir('libmalcontent') \ No newline at end of file diff --git a/po/meson.build b/po/meson.build index 8d7e350..0699f0e 100644 --- a/po/meson.build +++ b/po/meson.build @@ -1 +1 @@ -i18n.gettext('eos-parental-controls', preset: 'glib') \ No newline at end of file +i18n.gettext('malcontent', preset: 'glib') \ No newline at end of file From e22986d75c7b7eb7fd0cbb0530a68283049ab4b8 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 26 Feb 2019 17:48:03 +0000 Subject: [PATCH 4/6] docs: Port README to Markdown and update a few references Signed-off-by: Philip Withnall --- README => README.md | 18 +++++++----------- malcontent.doap | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) rename README => README.md (74%) diff --git a/README b/README.md similarity index 74% rename from README rename to README.md index a500a21..1a10d53 100644 --- a/README +++ b/README.md @@ -1,8 +1,8 @@ malcontent -===================== +========== malcontent implements support for restricting the abilities of -non-administrator accounts on an Endless OS system. Typically, when this is +non-administrator accounts on a Linux system. Typically, when this is used, a non-administrator account will be for a child using the system; and the administrator accounts will be for the parents. @@ -13,7 +13,7 @@ accessing and applying the app filter. All the library APIs are currently unstable and are likely to change wildly. Dependencies -============ +------------ • accounts-service • dbus-daemon @@ -22,16 +22,12 @@ Dependencies • gobject-2.0 ≥ 2.54 Licensing -========= +--------- All code in this project is licensed under LGPL-2.1+. See COPYING for more details. Bugs -==== +---- -Bug reports and patches should be filed in GitHub. - -Contact -======= - -https://gitlab.freedesktop.org/pwithnall/malcontent +Bug reports and patches should be filed in +[GitLab](https://gitlab.freedesktop.org/pwithnall/malcontent). diff --git a/malcontent.doap b/malcontent.doap index 7a8e2f6..c746cc4 100644 --- a/malcontent.doap +++ b/malcontent.doap @@ -1,7 +1,7 @@ malcontent - malcontent provides restrictions for children on EOS - malcontent implements support for restricting the abilities of non-administrator accounts on an Endless OS system. + malcontent provides restrictions for children on Linux systems + malcontent implements support for restricting the abilities of non-administrator accounts on a Linux system. From 6ff0d7225bbbe6d2d9912852dd0b97c92fa1160a Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 26 Feb 2019 17:48:19 +0000 Subject: [PATCH 5/6] build: Bump version number to 0.2.0 To differentiate it from the pre-rename version number, 0.1.0. Signed-off-by: Philip Withnall --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index bab2991..f4008a9 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,5 @@ project('malcontent', 'c', - version : '0.1.0', + version : '0.2.0', meson_version : '>= 0.47.0', license: 'LGPLv2.1+', default_options : [ From 0447d5e1f7641d808d6abda19524635ec6ce9bf2 Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Tue, 26 Feb 2019 17:51:09 +0000 Subject: [PATCH 6/6] ci: Add CI configuration Signed-off-by: Philip Withnall --- .gitlab-ci.yml | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 .gitlab-ci.yml diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..ed8ba31 --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,48 @@ +image: debian:unstable + +before_script: + - apt update -qq + - apt install -y -qq build-essential meson pkg-config gtk-doc-tools + libxml2-utils gobject-introspection + libgirepository1.0-dev libglib2.0-dev + gettext libdbus-1-dev libpolkit-gobject-1-dev git + policykit-1 lcov + - export LANG=C.UTF-8 + +stages: + - build + - deploy + +cache: + paths: + - _ccache/ + +debian-unstable: + stage: build + except: + - tags + script: + - git submodule update --init + - meson --buildtype debug --werror -Db_coverage=true -Ddocumentation=true _build . + - meson test -C _build + - ninja -C _build coverage + coverage: '/^\s+lines\.+:\s+([\d.]+\%)\s+/' + artifacts: + when: always + name: "malcontent-${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}" + paths: + - "_build/meson-logs" + +# FIXME: Run gtkdoc-check when we can. See: +# https://github.com/mesonbuild/meson/issues/3580 + +pages: + stage: deploy + only: + - master + script: + - mkdir -p public/ + - mv _build/meson-logs/coveragereport/ public/coverage/ + artifacts: + paths: + - public