Commit Graph

39 Commits

Author SHA1 Message Date
Philip Withnall 81964dec1f build: Re-add libglib-testing subproject
This time, add it as a wrap module rather than a git submodule. They’re
easier to manage, and integrate better with Meson.

The subproject has to be re-added so that malcontent can be built on
Debian Stable and Fedora 31 for the gnome-software CI. See
https://gitlab.gnome.org/GNOME/gnome-software/-/merge_requests/487.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-07 15:29:11 +01:00
Philip Withnall d085c7f585 build: Use meson.current_source_dir() instead of source_root()
The latter doesn’t work well when building as a subproject — it
explicitly refers to the parent project root.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-07-06 10:59:45 +01:00
Philip Withnall 73d7c5e113 all: Fix various typos and incorrect terminology
Done using:
```
codespell \
    --builtin clear,rare,usage \
    --skip './po/*' --skip './help/*/*.po' --skip './.git/*' --skip './NEWS*' \
    --write-changes .
```
and then some manual checking and editing.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-06-18 13:51:35 +01:00
Matthew Leeds 15e8a74b21 tree-wide: Replace usages of whitelist/blacklist
Replace usages of the terms whitelist and blacklist with the more
inclusive and more precise terms allowlist and blocklist, which are
actually also more consistent with parts of the codebase, e.g.
mct_app_filter_is_content_type_allowed().

The only API break here is in libmalcontent/app-filter.h but the
relevant API is not used anywhere else in Endless OS beyond this repo,
nor to my knowledge in any other distribution. Also, per the README,
this project's API is not stable, so now is a good time to make this
change.
2020-06-09 15:35:21 -07:00
Philip Withnall 28d496926d libmalcontent: Add a constructor to bind the translation domain
This ensures that the translation domain is loaded for malcontent as
soon as the library is loaded.

The same is not needed for libmalcontent-ui, because it always causes
libmalcontent to be loaded.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-27 12:10:58 +01:00
Philip Withnall d85126da9d build: Stop building libglib-testing as a subproject
Just add it as a dependency instead. It’s a lot less painful (git
submodules are still a pain to use; and `git evtag` doesn’t work well
with them); and libglib-testing has just done a 0.1.0 release which we
can depend on.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-15 15:03:39 +01:00
Philip Withnall 6f09483b4c libmalcontent: Clarify nullability of MctManager:connection
It’s not.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-07 12:52:15 +01:00
Philip Withnall aaca135199 libmalcontent: Add enum types to fix introspection of MctManagerError
Without a GType for the error enum, g-ir-scanner fails to properly
associate it with the error quark function, and (for example) error code
matching in JS doesn’t work.

This adds the enum types in a new public header file.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-04-04 00:37:26 +01:00
Philip Withnall 04705c079a session-limits: Add mct_session_limits_is_enabled() API
This is a high-level API to indicate whether parental controls are
‘enabled’ for the given user. It’s a mirror of
`mct_app_filter_is_enabled()`, and exposes the existing
`time_limit_enabled_out` argument of
`mct_session_limits_check_time_remaining()` more conveniently.

Includes tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-24 11:06:16 +00:00
Philip Withnall f106319fdd app-filter: Add mct_app_filter_is_enabled() API
This is a high-level API to indicate whether parental controls are
‘enabled’ for the given user. Specifically, whether any of the
properties of the `MctAppFilter` differ from their default value.

Includes tests.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-24 11:06:16 +00:00
Philip Withnall faa0b9a3eb app-filter: Factor out a helper function
This introduces no functional changes, but will make an upcoming change
a little simpler.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-24 11:06:16 +00:00
Philip Withnall 9fbcef0fb8 libmalcontent: Add a clarifying comment about nullability
This introduces no functional changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-24 11:06:16 +00:00
Philip Withnall 6ba767029f session-limits: Add serialize and deserialize methods
See the previous commit; this is the same, but for session limits.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-19 09:42:25 +00:00
Philip Withnall cba851fc27 app-filter: Add serialize and deserialize methods
Add methods to serialise and deserialise the app filter, and use them to
replace the code in `MctManager` which was previously doing this. This
exposes the variant format for the app filter in the API (although the
format is described as ‘opaque’) so that user code can log it or store
it separately.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-03-18 10:40:27 +00:00
Philip Withnall b98ec83e66 libmalcontent-ui: Add GIR dependency on libmalcontent
This was missing and causing some problems with GIR compilation for the
UI library.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-06 12:52:06 +00:00
Philip Withnall 2a3f0fd741 libmalcontent: Rework pkg-config file generation
Meson 0.49 has matured its pkg-config file generation a little, and the
API has subtly changed. The main library we’re building a pkg-config
file for is now passed as the first argument; and all dependencies can
be passed to `libraries`/`libraries_private`. Any dependencies which
provide pkg-config files will automatically be moved into the pkg-config
file’s `Requires`/`Requires.private` sections.

See https://mesonbuild.com/Pkgconfig-module.html#implicit-dependencies

This bumps our Meson dependency to ≥ 0.49.0.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-04 11:34:05 +00:00
Philip Withnall 93d18ed2a9 libmalcontent: Add type macros for boxed types
These were accidentally missed out before.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-02-03 17:29:17 +00:00
Philip Withnall ec1af3ef55 tests: Add tests for SessionLimits interface
This adds tests for the getter and setter for session limits, giving us
65.9% branch coverage (but that includes `g_return_if_fail()` and
friends, which are impossible and pointless to test both sides of the
branch).

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall ee7ed7dc35 libmalcontent: Add support for setting session limits
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 5e49cb7831 libmalcontent: Add a SessionLimits interface for time-limited sessions
This is another extension interface on accountsservice which stores
information about time and usage limits on the user session. Currently,
only a ‘daily schedule’ limit (or no limit) is supported, but additional
types and combinations of limits can be supported in future.

The daily schedule limit allows using the computer between a certain
start time and end time each day (the same each day). The user will be
kicked out of their session when the end time is reached, if they
haven’t already logged out.

This includes the getters for the new data, polkit rules for accessing
it, and some documentation. Changes to `malcontent-client` to support
session limits, setters, and unit tests will all follow.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 9dcaa10253 libmalcontent: Drop an unused variable
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 300b5a624f libmalcontent: Move MctAppFilterError to MctManagerError
This isn’t an API break, as compatibility defines are in place; and the
error code values are the same, so it shouldn’t be an ABI break. The
string value of the error quark has changed, but nobody should be
comparing that against a value which hasn’t come out of libmalcontent,
so changing it should be OK.

This is along the same lines as the previous commit: we don’t need one
error domain per property of an `MctManager`, so reduce the potential
for future duplication by renaming it now.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall acf2738d56 libmalcontent: Rename flags types
If we have a flag type for getting and for setting every type of value
which can be stored on an `MctManager`, that will lead to a load of flag
types which all look identical.

Refactor the types so we only have one shared flags type for getters,
and one for setters.

Add compatibility defines so that this doesn’t break API. It’s not an
ABI break because the flag member values don’t change.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 282cf9c66b libmalcontent: Set flag-like values for flag types
Previously these flags were using automatically assigned enum values,
which would have eventually resulted in having more than one bit set per
flag. Fix that before it happens by explicitly assigning flag-like
values. This was an oversight when they were first written.

This introduces no functional changes because both enums only had one
element so far.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Philip Withnall 5f2d4046ea libmalcontent: Fix a minor typo in a comment
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2020-01-16 13:17:45 +00:00
Umang Jain b6b8873261 docs: Improve documentation of "app-filter-changed" signal 2019-06-18 19:23:17 +05:30
Andre Moreira Magalhaes 3800cd3818 libmalcontent: Add tests for filtering by content type
Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes da0e63fe99 libmalcontent: Add support for filtering by content type
This is useful for example if blacklisting all apps that can
handle certain content types is desired.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Andre Moreira Magalhaes bbd1b2bdff libmalcontent: Rename app filter paths_blacklist member to blacklist
The filter blacklist also holds information on flatpak refs that are
blacklisted (apart from paths), so lets rename it for clarity.

Signed-off-by: Andre Moreira Magalhaes <andre@endlessm.com>
2019-06-14 15:55:27 +00:00
Philip Withnall 418b79ab7f tests: Use g_assert_cmpvariant() from GLib 2.60
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-13 16:40:52 +01:00
Philip Withnall d9acee829a tests: Use gdbus-codegen to drop hand-coded interface definitions
Bump our GLib dependency to 2.60 so we can use `gdbus-codegen
--interface-info-{body,header}` to generate interface definitions
dynamically rather than hand-coding them.

We actually need to depend on 2.60.1 so we get
https://gitlab.gnome.org/GNOME/glib/merge_requests/721.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-06-13 16:40:52 +01:00
Philip Withnall 30cbeda0ae libmalcontent: Add missing field initialisers to BUILDER_INIT
This fixes use of libmalcontent in projects which build with
`-Wmissing-field-initializers`.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-05-15 14:31:02 +01:00
Philip Withnall ad45f2813b libmalcontent: Add a top-level header file
This just simplifies including the malcontent headers from projects
which use it.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-25 16:56:02 +01:00
Philip Withnall 2048f0d483 libmalcontent: Add MctManager::app-filter-changed signal
This is emitted when the app filter for a given user changes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.freedesktop.org/pwithnall/malcontent/issues/1
2019-04-24 13:45:59 +01:00
Philip Withnall 68ebe8b568 libmalcontent: Factor getting/setting app filter into a manager
Create a new MctManager object which is used as the anchor for getting
or setting MctAppFilters.

This changes the API naming around quite a bit, but doesn’t really
change its behaviour or functionality — see the tests for examples of
how little things change.

This is one step on the way to emitting a signal (from MctManager) when
a user’s parental controls change.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

https://gitlab.freedesktop.org/pwithnall/malcontent/issues/1
2019-04-24 13:45:59 +01:00
Philip Withnall 9fb9b75b57 libmalcontent: Drop an unused variable
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-24 11:06:28 +01:00
Philip Withnall a378e28237 libmalcontent: Add MCT_APP_FILTER_ERROR_DISABLED error
This indicates that app filtering is disabled globally, perhaps because
it’s not installed in accountsservice properly.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-04-24 11:06:28 +01:00
Philip Withnall 3f3bb6ee54 lib: Change allow_interactive_authorization bool to flags
This is an API break for the mct_{get,set}_app_filter() APIs, but makes
them a bit clearer to use, and a little more future proof.

This includes updates to all the tests and documentation.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-03-19 16:56:58 +00:00
Philip Withnall 03436eacf5 Rename project from eos-parental-controls to malcontent
Rename the library from libeos-parental-controls to libmalcontent, and
the client from eos-parental-controls-client to malcontent-client.

This was done using the following mechanical edits, and no other
changes:
```
git search-replace -f EPC///MCT
git search-replace -f Epc///Mct
git search-replace -f epc///mct
git search-replace -f eos_parental_controls///malcontent
git search-replace -f eos-parental-controls///malcontent
git search-replace -f EosParentalControls///Malcontent
git search-replace -f 'eos\\-parental\\-controls///malcontent'
git search-replace -f 'Since: 0.1.0///Since: 0.2.0'
```

Note that the accounts-service extension interface has *not* been
renamed, as that would revert people’s parental controls settings in
existing deployments.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-26 17:45:14 +00:00