Revert "policy: Remove policy for removed features"

This reverts commit ababfa2aaf.

Changes:
1. Drop the policy for the old APIs.
2. Add a policy for enableChargeLimit.
This commit is contained in:
Kate Hsuan 2024-08-08 16:08:01 +08:00
parent 293e00e0f9
commit 7011b93c28
3 changed files with 62 additions and 0 deletions

View file

@ -121,6 +121,11 @@ if systemdsystemunitdir == ''
systemdsystemunitdir = systemd_dep.get_variable(pkgconfig: 'systemdsystemunitdir')
endif
datadir = get_option('datadir')
if datadir == ''
datadir = join_paths(prefix, get_option('datadir'))
endif
# Generate configuration file
config_h = configure_file(output: 'config.h', configuration: cdata)
@ -132,6 +137,7 @@ subdir('libupower-glib')
subdir('src')
subdir('tools')
subdir('doc')
subdir('policy')
pkgconfig = import('pkgconfig')
pkgconfig.generate(

24
policy/meson.build Normal file
View file

@ -0,0 +1,24 @@
if polkit.found()
#newer polkit has the ITS rules included
if polkit.version().version_compare('>0.113')
i18n.merge_file(
input: 'org.freedesktop.upower.policy.in',
output: 'org.freedesktop.upower.policy',
install: true,
install_dir: join_paths(datadir, 'polkit-1', 'actions') ,
type: 'xml',
po_dir: join_paths(meson.project_source_root(), 'po')
)
#older polkit is missing ITS rules and will fail
else
i18n.merge_file(
input: 'org.freedesktop.upower.policy.in',
output: 'org.freedesktop.upower.policy',
install: true,
install_dir: join_paths(datadir, 'polkit-1', 'actions') ,
type: 'xml',
data_dirs: join_paths(meson.project_source_root(), 'policy'),
po_dir: join_paths(meson.project_source_root(), 'po')
)
endif
endif

View file

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE policyconfig PUBLIC
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
"http://www.freedesktop.org/standards/PolicyKit/1.0/policyconfig.dtd">
<!--
Policy definitions for UPower
Copyright (c) 2008 David Zeuthen <david@fubar.dk>
Copyright (c) 2008-2010 Richard Hughes <richard@hughsie.com>
NOTE: If you make changes to this file, make sure to validate the file
using the polkit-policy-file-validate(1) tool. Changes made to this
file are instantly applied.
-->
<policyconfig>
<vendor>The UPower Project</vendor>
<vendor_url>http://upower.freedesktop.org/</vendor_url>
<icon_name>system-suspend</icon_name>
<action id="org.freedesktop.UPower.enable-charging-limit">
<_description>Enable battery charging limit</_description>
<_message>Authentication is required to set battery charging start and end limit.</_message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>yes</allow_active>
</defaults>
</action>
</policyconfig>