Merge branch 'rename' into 'master'
Rename project See merge request pwithnall/malcontent!1
This commit is contained in:
commit
e000f2ab6c
|
@ -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
|
|
@ -1,8 +1,8 @@
|
|||
eos-parental-controls
|
||||
=====================
|
||||
malcontent
|
||||
==========
|
||||
|
||||
eos-parental-controls implements support for restricting the abilities of
|
||||
non-administrator accounts on an Endless OS system. Typically, when this is
|
||||
malcontent implements support for restricting the abilities of
|
||||
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,17 +22,12 @@ Dependencies
|
|||
• gobject-2.0 ≥ 2.54
|
||||
|
||||
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
|
||||
====
|
||||
----
|
||||
|
||||
Bug reports and patches should be filed in GitHub.
|
||||
|
||||
Contact
|
||||
=======
|
||||
|
||||
https://github.com/endlessm/eos-parental-controls
|
||||
Bug reports and patches should be filed in
|
||||
[GitLab](https://gitlab.freedesktop.org/pwithnall/malcontent).
|
|
@ -1,5 +0,0 @@
|
|||
eos-parental-controls (0) UNRELEASED; urgency=low
|
||||
|
||||
* Initial release (Closes: T23859)
|
||||
|
||||
-- Philip Withnall <withnall@endlessm.com> Fri, 05 Oct 2018 23:36:00 +0100
|
|
@ -1 +0,0 @@
|
|||
10
|
|
@ -1,94 +0,0 @@
|
|||
Source: eos-parental-controls
|
||||
Section: misc
|
||||
Priority: optional
|
||||
Maintainer: Philip Withnall <withnall@endlessm.com>
|
||||
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.
|
|
@ -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 <withnall@endlessm.com>
|
||||
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
|
|
@ -1 +0,0 @@
|
|||
README
|
|
@ -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
|
|
@ -1,2 +0,0 @@
|
|||
usr/bin/eos-parental-controls-client
|
||||
usr/share/man/man8/eos-parental-controls-client.8*
|
|
@ -1,6 +0,0 @@
|
|||
[DEFAULT]
|
||||
debian-tag = Version_%(version)s
|
||||
debian-branch = master
|
||||
|
||||
[dch]
|
||||
ignore-branch = True
|
|
@ -1 +0,0 @@
|
|||
usr/lib/*/girepository-1.0/EosParentalControls-0.*
|
|
@ -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
|
|
@ -1,2 +0,0 @@
|
|||
usr/lib/*/installed-tests/libeos-parental-controls-0
|
||||
usr/share/installed-tests/libeos-parental-controls-0
|
|
@ -1 +0,0 @@
|
|||
usr/lib/*/libeos-parental-controls-0.so*
|
|
@ -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
|
|
@ -1 +0,0 @@
|
|||
3.0 (native)
|
|
@ -1,4 +0,0 @@
|
|||
Tests: gnome-desktop-testing
|
||||
Depends:
|
||||
gnome-desktop-testing,
|
||||
libeos-parental-controls-0-tests,
|
|
@ -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 \
|
||||
--
|
|
@ -1,11 +0,0 @@
|
|||
# Python program
|
||||
install_data('eos-parental-controls-client.py',
|
||||
install_dir: bindir,
|
||||
install_mode: 'rwxr-xr-x',
|
||||
rename: ['eos-parental-controls-client'],
|
||||
)
|
||||
|
||||
# Documentation
|
||||
install_man('docs/eos-parental-controls-client.8')
|
||||
|
||||
# TODO subdir('tests')
|
|
@ -1,8 +0,0 @@
|
|||
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns="http://usefulinc.com/ns/doap#">
|
||||
<name xml:lang="en">eos-parental-controls</name>
|
||||
<shortdesc xml:lang="en">eos-parental-controls provides restrictions for children on EOS</shortdesc>
|
||||
<description xml:lang="en">eos-parental-controls implements support for restricting the abilities of non-administrator accounts on an Endless OS system.</description>
|
||||
<homepage rdf:resource="https://github.com/endlessm/eos-parental-controls"/>
|
||||
<license rdf:resource="http://usefulinc.com/doap/licenses/lgpl"/>
|
||||
<download-page rdf:resource="https://github.com/endlessm/eos-parental-controls"/>
|
||||
</Project>
|
|
@ -1,62 +0,0 @@
|
|||
libeos_parental_controls_api_version = '0'
|
||||
libeos_parental_controls_api_name = 'eos-parental-controls-' + libeos_parental_controls_api_version
|
||||
libeos_parental_controls_sources = [
|
||||
'app-filter.c',
|
||||
]
|
||||
libeos_parental_controls_headers = [
|
||||
'app-filter.h',
|
||||
]
|
||||
|
||||
libeos_parental_controls_public_deps = [
|
||||
dependency('gio-2.0', version: '>= 2.44'),
|
||||
dependency('glib-2.0', version: '>= 2.54.2'),
|
||||
dependency('gobject-2.0', version: '>= 2.54'),
|
||||
]
|
||||
libeos_parental_controls_private_deps = [
|
||||
dependency('gio-unix-2.0', version: '>= 2.36'),
|
||||
]
|
||||
|
||||
# FIXME: Would be good to use subdir here: https://github.com/mesonbuild/meson/issues/2969
|
||||
libeos_parental_controls_include_subdir = join_paths(libeos_parental_controls_api_name, 'libeos-parental-controls')
|
||||
|
||||
libeos_parental_controls = library(libeos_parental_controls_api_name,
|
||||
libeos_parental_controls_sources + libeos_parental_controls_headers,
|
||||
dependencies: libeos_parental_controls_public_deps + libeos_parental_controls_private_deps,
|
||||
include_directories: root_inc,
|
||||
install: true,
|
||||
version: meson.project_version(),
|
||||
soversion: libeos_parental_controls_api_version,
|
||||
)
|
||||
libeos_parental_controls_dep = declare_dependency(
|
||||
link_with: libeos_parental_controls,
|
||||
include_directories: root_inc,
|
||||
)
|
||||
|
||||
# Public library bits.
|
||||
install_headers(libeos_parental_controls_headers,
|
||||
subdir: libeos_parental_controls_include_subdir,
|
||||
)
|
||||
|
||||
pkgconfig.generate(
|
||||
libraries: [ libeos_parental_controls ],
|
||||
subdirs: libeos_parental_controls_api_name,
|
||||
version: meson.project_version(),
|
||||
name: 'libeos-parental-controls',
|
||||
filebase: libeos_parental_controls_api_name,
|
||||
description: 'Library providing access to parental control settings.',
|
||||
requires: libeos_parental_controls_public_deps,
|
||||
requires_private: libeos_parental_controls_private_deps,
|
||||
)
|
||||
|
||||
gnome.generate_gir(libeos_parental_controls,
|
||||
sources: libeos_parental_controls_sources + libeos_parental_controls_headers,
|
||||
nsversion: libeos_parental_controls_api_version,
|
||||
namespace: 'EosParentalControls',
|
||||
symbol_prefix: 'epc_',
|
||||
identifier_prefix: 'Epc',
|
||||
export_packages: 'libeos-parental-controls',
|
||||
includes: ['GObject-2.0', 'Gio-2.0'],
|
||||
install: true,
|
||||
)
|
||||
|
||||
subdir('tests')
|
File diff suppressed because it is too large
Load Diff
|
@ -29,57 +29,57 @@
|
|||
G_BEGIN_DECLS
|
||||
|
||||
/**
|
||||
* 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
|
|
@ -0,0 +1,62 @@
|
|||
libmalcontent_api_version = '0'
|
||||
libmalcontent_api_name = 'malcontent-' + libmalcontent_api_version
|
||||
libmalcontent_sources = [
|
||||
'app-filter.c',
|
||||
]
|
||||
libmalcontent_headers = [
|
||||
'app-filter.h',
|
||||
]
|
||||
|
||||
libmalcontent_public_deps = [
|
||||
dependency('gio-2.0', version: '>= 2.44'),
|
||||
dependency('glib-2.0', version: '>= 2.54.2'),
|
||||
dependency('gobject-2.0', version: '>= 2.54'),
|
||||
]
|
||||
libmalcontent_private_deps = [
|
||||
dependency('gio-unix-2.0', version: '>= 2.36'),
|
||||
]
|
||||
|
||||
# FIXME: Would be good to use subdir here: https://github.com/mesonbuild/meson/issues/2969
|
||||
libmalcontent_include_subdir = join_paths(libmalcontent_api_name, 'libmalcontent')
|
||||
|
||||
libmalcontent = library(libmalcontent_api_name,
|
||||
libmalcontent_sources + libmalcontent_headers,
|
||||
dependencies: libmalcontent_public_deps + libmalcontent_private_deps,
|
||||
include_directories: root_inc,
|
||||
install: true,
|
||||
version: meson.project_version(),
|
||||
soversion: libmalcontent_api_version,
|
||||
)
|
||||
libmalcontent_dep = declare_dependency(
|
||||
link_with: libmalcontent,
|
||||
include_directories: root_inc,
|
||||
)
|
||||
|
||||
# Public library bits.
|
||||
install_headers(libmalcontent_headers,
|
||||
subdir: libmalcontent_include_subdir,
|
||||
)
|
||||
|
||||
pkgconfig.generate(
|
||||
libraries: [ libmalcontent ],
|
||||
subdirs: libmalcontent_api_name,
|
||||
version: meson.project_version(),
|
||||
name: 'libmalcontent',
|
||||
filebase: libmalcontent_api_name,
|
||||
description: 'Library providing access to parental control settings.',
|
||||
requires: libmalcontent_public_deps,
|
||||
requires_private: libmalcontent_private_deps,
|
||||
)
|
||||
|
||||
gnome.generate_gir(libmalcontent,
|
||||
sources: libmalcontent_sources + libmalcontent_headers,
|
||||
nsversion: libmalcontent_api_version,
|
||||
namespace: 'Malcontent',
|
||||
symbol_prefix: 'mct_',
|
||||
identifier_prefix: 'Mct',
|
||||
export_packages: 'libmalcontent',
|
||||
includes: ['GObject-2.0', 'Gio-2.0'],
|
||||
install: true,
|
||||
)
|
||||
|
||||
subdir('tests')
|
|
@ -25,7 +25,7 @@
|
|||
#include <glib.h>
|
||||
#include <gio/gdesktopappinfo.h>
|
||||
#include <gio/gio.h>
|
||||
#include <libeos-parental-controls/app-filter.h>
|
||||
#include <libmalcontent/app-filter.h>
|
||||
#include <libglib-testing/dbus-queue.h>
|
||||
#include <locale.h>
|
||||
#include <string.h>
|
||||
|
@ -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);
|
||||
|
|
@ -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()
|
|
@ -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
|
|
@ -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)
|
||||
|
|
@ -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')
|
|
@ -0,0 +1,8 @@
|
|||
<Project xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns="http://usefulinc.com/ns/doap#">
|
||||
<name xml:lang="en">malcontent</name>
|
||||
<shortdesc xml:lang="en">malcontent provides restrictions for children on Linux systems</shortdesc>
|
||||
<description xml:lang="en">malcontent implements support for restricting the abilities of non-administrator accounts on a Linux system.</description>
|
||||
<homepage rdf:resource="https://gitlab.freedesktop.org/pwithnall/malcontent"/>
|
||||
<license rdf:resource="http://usefulinc.com/doap/licenses/lgpl"/>
|
||||
<download-page rdf:resource="https://gitlab.freedesktop.org/pwithnall/malcontent"/>
|
||||
</Project>
|
|
@ -1,5 +1,5 @@
|
|||
project('eos-parental-controls', 'c',
|
||||
version : '0.1.0',
|
||||
project('malcontent', 'c',
|
||||
version : '0.2.0',
|
||||
meson_version : '>= 0.47.0',
|
||||
license: 'LGPLv2.1+',
|
||||
default_options : [
|
||||
|
@ -119,5 +119,5 @@ test_env = [
|
|||
]
|
||||
|
||||
subdir('accounts-service')
|
||||
subdir('eos-parental-controls-client')
|
||||
subdir('libeos-parental-controls')
|
||||
subdir('malcontent-client')
|
||||
subdir('libmalcontent')
|
|
@ -1 +1 @@
|
|||
i18n.gettext('eos-parental-controls', preset: 'glib')
|
||||
i18n.gettext('malcontent', preset: 'glib')
|
Loading…
Reference in New Issue