Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a background monitor #319

Merged
merged 23 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ AC_PATH_PROG([BWRAP], [bwrap])
AC_SUBST([GLIB_COMPILE_RESOURCES], [`$PKG_CONFIG --variable glib_compile_resources gio-2.0`])
AC_SUBST([GDBUS_CODEGEN], [`$PKG_CONFIG --variable gdbus_codegen gio-2.0`])

PKG_CHECK_MODULES(BASE, [glib-2.0 gio-2.0 gio-unix-2.0 fontconfig])
PKG_CHECK_MODULES(BASE, [glib-2.0 gio-2.0 gio-unix-2.0 fontconfig json-glib-1.0])
AC_SUBST(BASE_CFLAGS)
AC_SUBST(BASE_LIBS)

Expand Down Expand Up @@ -136,7 +136,6 @@ fi
GLIB_TESTS

PKG_CHECK_MODULES(FUSE, [fuse])
PKG_CHECK_MODULES(FLATPAK, [flatpak])

AC_CONFIG_FILES([
Makefile
Expand Down
2 changes: 2 additions & 0 deletions data/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ dist_introspection_DATA = \
data/org.freedesktop.portal.RemoteDesktop.xml \
data/org.freedesktop.portal.Location.xml \
data/org.freedesktop.portal.Settings.xml \
data/org.freedesktop.portal.Background.xml \
data/org.freedesktop.impl.portal.PermissionStore.xml \
data/org.freedesktop.impl.portal.Request.xml \
data/org.freedesktop.impl.portal.Session.xml \
Expand All @@ -35,4 +36,5 @@ dist_introspection_DATA = \
data/org.freedesktop.impl.portal.RemoteDesktop.xml \
data/org.freedesktop.impl.portal.Settings.xml \
data/org.freedesktop.impl.portal.Lockdown.xml \
data/org.freedesktop.impl.portal.Background.xml \
$(NULL)
105 changes: 105 additions & 0 deletions data/org.freedesktop.impl.portal.Background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2019 Red Hat, 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 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, see <http://www.gnu.org/licenses/>.

Author: Matthias Clasen <[email protected]>
-->

<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<!--
org.freedesktop.impl.portal.Background:
@short_description: Background portal backend interface

This interface provides APIs related to applications
that are running in the background.
-->
<interface name="org.freedesktop.impl.portal.Background">

<!--
GetAppState:
@apps: an array with information about running apps

Gets information about running apps. Each entry has
an application ID as key. The returned values are of
type u and have the following meaning:
<simplelist>
<member>0: Background (no open window)</member>
<member>1: Running (at least one open window)</member>
<member>2: Active (in the foreground)</member>
</simplelist>
-->
<method name='GetAppState'>
<arg type="a{sv}" name="apps" direction="out"/>
</method>

<!--
NotifyBackground:
@handle: Object path for the #org.freedesktop.impl.portal.Request object representing this call
@app_id: App id of the application
@name: A display name for the application
@response: Numeric response, not used
@results: Vardict with results of the call

Notifies the user that an application is running in the background.

The following results get returned via the @results vardict:
<variablelist>
<varlistentry>
<term>result u</term>
<listitem><para>
The choice that the user made regarding the background
activity:
<simplelist>
<member>0: Forbid background activity by this app</member>
<member>1: Allow background activity by this app</member>
<member>2: Allow this instance of background activity</member>
</simplelist>
</para></listitem>
</varlistentry>
</variablelist>
-->
<method name='NotifyBackground'>
<arg type="o" name="handle" direction="in"/>
<arg type="s" name="app_id" direction="in"/>
<arg type="s" name="name" direction="in"/>
<arg type="u" name="response" direction="out"/>
<arg type="a{sv}" name="results" direction="out"/>
</method>

<!--
EnableAutostart:
@app_id: App id of the application
@enable: TRUE to enable autostart, FALSE to disable it
@commandline: The commandline to use in the autostart file
@flags: Flags influencing the details of the autostarting
@result: TRUE if autostart was enabled, FALSE otherwise

Enables or disables autostart for an application.

The following flags are understood:
<simplelist>
<member>1: Use D-Bus activation</member>
</simplelist>
-->
<method name='EnableAutostart'>
<arg type="s" name="app_id" direction="in"/>
<arg type="b" name="enable" direction="in"/>
<arg type="as" name="commandline" direction="in"/>
<arg type="u" name="flags" direction="in"/>
<arg type="b" name="result" direction="out"/>
</method>
</interface>
</node>
109 changes: 109 additions & 0 deletions data/org.freedesktop.portal.Background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0"?>
<!--
Copyright (C) 2019 Red Hat, 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 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, see <http://www.gnu.org/licenses/>.

Author: Matthias Clasen <[email protected]>
-->

<node name="/" xmlns:doc="http://www.freedesktop.org/dbus/1.0/doc.dtd">
<!--
org.freedesktop.portal.Background:
@short_description: Portal for requesting autostart and background activity

This simple interface lets sandboxed applications request that
the application is allowed to run in the background or started
automatically when the user logs in.

This documentation describes version 1 of this interface.
-->
<interface name="org.freedesktop.portal.Background">
<!--
RequestBackground:
@parent_window: Identifier for the application window, see <lin
k linkend="parent_window">Common Conventions</link>
@options: Vardict with optional further information
@handle: Object path for the #org.freedesktop.portal.Request object representing this call

Requests that the application is allowed to run in the
background.

Supported keys in the @options vardict include:
<variablelist>
<varlistentry>
<term>handle_token s</term>
<listitem><para>
A string that will be used as the last element of the
@handle. Must be a valid object path element. See the
#org.freedesktop.portal.Request documentation for more
information about the @handle.
</para></listitem>
</varlistentry>
<varlistentry>
<term>reason s</term>
<listitem><para>
User-visible reason for the request.
</para></listitem>
</varlistentry>
<varlistentry>
<term>autostart b</term>
<listitem><para>
TRUE if the app also wants to be started automatically
at login.
</para></listitem>
</varlistentry>
<varlistentry>
<term>commandline as</term>
<listitem><para>
Commandline to use add when autostarting at login.
If this is not specified, the Exec line from the
desktop file will be used.
</para></listitem>
</varlistentry>
<varlistentry>
<term>dbus-activatable b</term>
<listitem><para>
If TRUE, use D-Bus activation for autostart.
</para></listitem>
</varlistentry>
</variablelist>

The following results get returned via the
#org.freedesktop.portal.Request::Response signal:

<variablelist>
<varlistentry>
<term>background b</term>
<listitem><para>
TRUE if the application is allowed to run in the background.
</para></listitem>
</varlistentry>
<varlistentry>
<term>autostart b</term>
<listitem><para>
TRUE if the application is will be autostarted.
</para></listitem>
</varlistentry>
</variablelist>
-->
<method name="RequestBackground">
<arg type="s" name="parent_window" direction="in"/>
<arg type="a{sv}" name="options" direction="in"/>
<arg type="o" name="handle" direction="out"/>
</method>

<property name="version" type="u" access="read"/>
</interface>
</node>
3 changes: 3 additions & 0 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ portal_files = \
$(top_srcdir)/data/org.freedesktop.portal.Device.xml \
$(top_srcdir)/data/org.freedesktop.portal.Location.xml \
$(top_srcdir)/data/org.freedesktop.portal.Settings.xml \
$(top_srcdir)/data/org.freedesktop.portal.Background.xml \
$(top_srcdir)/data/org.freedesktop.impl.portal.Request.xml \
$(top_srcdir)/data/org.freedesktop.impl.portal.Session.xml \
$(top_srcdir)/data/org.freedesktop.impl.portal.FileChooser.xml \
Expand All @@ -38,6 +39,7 @@ portal_files = \
$(top_srcdir)/data/org.freedesktop.impl.portal.Lockdown.xml \
$(top_srcdir)/data/org.freedesktop.portal.Documents.xml \
$(top_srcdir)/data/org.freedesktop.impl.portal.PermissionStore.xml \
$(top_srcdir)/data/org.freedesktop.impl.portal.Background.xml \
$(NULL)

xml_files = \
Expand All @@ -60,6 +62,7 @@ xml_files = \
portal-org.freedesktop.portal.Device.xml \
portal-org.freedesktop.portal.Location.xml \
portal-org.freedesktop.portal.Settings.xml \
portal-org.freedesktop.portal.Background.xml \
portal-org.freedesktop.impl.portal.Request.xml \
portal-org.freedesktop.impl.portal.Session.xml \
portal-org.freedesktop.impl.portal.FileChooser.xml \
Expand Down
2 changes: 2 additions & 0 deletions doc/portal-docs.xml.in
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<xi:include href="portal-org.freedesktop.portal.NetworkMonitor.xml"/>
<xi:include href="portal-org.freedesktop.portal.ProxyResolver.xml"/>
<xi:include href="portal-org.freedesktop.portal.Settings.xml"/>
<xi:include href="portal-org.freedesktop.portal.Background.xml"/>
<xi:include href="portal-org.freedesktop.portal.Documents.xml"/>
<xi:include href="portal-org.freedesktop.portal.Flatpak.xml"/>
</reference>
Expand Down Expand Up @@ -145,6 +146,7 @@
<xi:include href="portal-org.freedesktop.impl.portal.Access.xml"/>
<xi:include href="portal-org.freedesktop.impl.portal.Settings.xml"/>
<xi:include href="portal-org.freedesktop.impl.portal.Lockdown.xml"/>
<xi:include href="portal-org.freedesktop.impl.portal.Background.xml"/>
<xi:include href="portal-org.freedesktop.impl.portal.PermissionStore.xml"/>
</reference>
</book>
6 changes: 6 additions & 0 deletions src/Makefile.am.inc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ PORTAL_IFACE_FILES =\
data/org.freedesktop.portal.RemoteDesktop.xml \
data/org.freedesktop.portal.Location.xml \
data/org.freedesktop.portal.Settings.xml \
data/org.freedesktop.portal.Background.xml \
$(NULL)

PORTAL_IMPL_IFACE_FILES =\
Expand All @@ -54,6 +55,7 @@ PORTAL_IMPL_IFACE_FILES =\
data/org.freedesktop.impl.portal.RemoteDesktop.xml \
data/org.freedesktop.impl.portal.Settings.xml \
data/org.freedesktop.impl.portal.Lockdown.xml \
data/org.freedesktop.impl.portal.Background.xml \
$(NULL)

$(xdp_dbus_built_sources) : $(PORTAL_IFACE_FILES)
Expand Down Expand Up @@ -147,6 +149,10 @@ xdg_desktop_portal_SOURCES = \
src/xdp-utils.h \
src/fc-monitor.c \
src/fc-monitor.h \
src/background.c \
src/background.h \
src/flatpak-instance.c \
src/flatpak-instance.h \
$(NULL)

if HAVE_PIPEWIRE
Expand Down
Loading