diff options
Diffstat (limited to 'src/modules/gsettings')
-rw-r--r-- | src/modules/gsettings/gsettings-helper.c | 134 | ||||
-rw-r--r-- | src/modules/gsettings/meson.build | 38 | ||||
-rw-r--r-- | src/modules/gsettings/meson_post_install.py | 14 | ||||
-rw-r--r-- | src/modules/gsettings/module-gsettings.c | 118 | ||||
-rw-r--r-- | src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml | 115 | ||||
-rw-r--r-- | src/modules/gsettings/pulseaudio.convert | 160 |
6 files changed, 579 insertions, 0 deletions
diff --git a/src/modules/gsettings/gsettings-helper.c b/src/modules/gsettings/gsettings-helper.c new file mode 100644 index 0000000..1bf2f13 --- /dev/null +++ b/src/modules/gsettings/gsettings-helper.c @@ -0,0 +1,134 @@ +/*** + This file is part of PulseAudio. + + PulseAudio 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. + + PulseAudio 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 + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. +***/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <string.h> +#include <stdlib.h> +#include <stdio.h> + +#include <gio/gio.h> +#include <glib.h> + +#include <pulsecore/core-util.h> + +#define PA_GSETTINGS_MODULE_GROUP_SCHEMA "org.freedesktop.pulseaudio.module-group" +#define PA_GSETTINGS_MODULE_GROUPS_SCHEMA "org.freedesktop.pulseaudio.module-groups" +#define PA_GSETTINGS_MODULE_GROUPS_PATH "/org/freedesktop/pulseaudio/module-groups/" + +static void handle_module_group(gchar *name) { + GSettings *settings; + gchar p[1024]; + gboolean enabled; + int i; + + pa_snprintf(p, sizeof(p), PA_GSETTINGS_MODULE_GROUPS_PATH"%s/", name); + + if (!(settings = g_settings_new_with_path(PA_GSETTINGS_MODULE_GROUP_SCHEMA, + p))) + return; + + enabled = g_settings_get_boolean(settings, "enabled"); + + printf("%c%s%c", enabled ? '+' : '-', name, 0); + + if (enabled) { + for (i = 0; i < 10; i++) { + gchar *n, *a; + + pa_snprintf(p, sizeof(p), "name%d", i); + n = g_settings_get_string(settings, p); + + pa_snprintf(p, sizeof(p), "args%i", i); + a = g_settings_get_string(settings, p); + + printf("%s%c%s%c", n, 0, a, 0); + + g_free(n); + g_free(a); + } + + printf("%c", 0); + } + + fflush(stdout); + + g_object_unref(G_OBJECT(settings)); +} + +static void module_group_callback(GSettings *settings, gchar *key, gpointer user_data) { + handle_module_group(user_data); +} + +int main(int argc, char *argv[]) { + GMainLoop *g; + GSettings *settings; + GPtrArray *groups; + gchar **group_names, **name; + +#if !GLIB_CHECK_VERSION(2,36,0) + g_type_init(); +#endif + + /* gsettings-data-convert copies data from GConf to GSettings. The + * conversion is defined in the pulseaudio.convert file. The conversion is + * done only once, so running the command every time gsettings-helper + * starts is safe. */ + g_spawn_command_line_sync("gsettings-data-convert", NULL, NULL, NULL, NULL); + + if (!(settings = g_settings_new(PA_GSETTINGS_MODULE_GROUPS_SCHEMA))) + goto fail; + + groups = g_ptr_array_new_full(0, g_object_unref); + group_names = g_settings_list_children(settings); + + for (name = group_names; *name; name++) { + GSettings *child = g_settings_get_child(settings, *name); + + /* The child may have been removed between the + * g_settings_list_children() and g_settings_get_child() calls. */ + if (!child) + continue; + + g_ptr_array_add(groups, child); + g_signal_connect(child, "changed", (GCallback) module_group_callback, *name); + handle_module_group(*name); + } + + /* Signal the parent that we are now initialized */ + printf("!"); + fflush(stdout); + + g = g_main_loop_new(NULL, FALSE); + g_main_loop_run(g); + g_main_loop_unref(g); + + g_ptr_array_unref(groups); + + /* group_names can't be freed earlier, because the values are being used as + * the user_data for module_group_callback(). */ + g_strfreev(group_names); + + g_object_unref(G_OBJECT(settings)); + + return 0; + +fail: + return 1; +} diff --git a/src/modules/gsettings/meson.build b/src/modules/gsettings/meson.build new file mode 100644 index 0000000..68a72c3 --- /dev/null +++ b/src/modules/gsettings/meson.build @@ -0,0 +1,38 @@ +# GSettings helper + +gsettings_helper_sources = [ + 'gsettings-helper.c', +] + +gsettings_helper = executable('gsettings-helper', + gsettings_helper_sources, + c_args : pa_c_args, + include_directories : [configinc, topinc], + link_with : [libpulsecommon, libpulse], + dependencies : [gio_dep], + install_dir : pulselibexecdir, + install_rpath : privlibdir, + install : true, +) + +# GSettings schemas + +compile_schemas = find_program('glib-compile-schemas', required : false) +if compile_schemas.found() + test('Validate schema files in ' + meson.current_source_dir(), + compile_schemas, + args: ['--strict', '--dry-run', meson.current_source_dir()] + ) +endif + +install_data('org.freedesktop.pulseaudio.gschema.xml', + install_dir : join_paths(datadir, 'glib-2.0', 'schemas') +) + +meson.add_install_script('meson_post_install.py', datadir) + +# Conversion from GConf to GSettings + +install_data('pulseaudio.convert', + install_dir : join_paths(datadir, 'GConf', 'gsettings') +) diff --git a/src/modules/gsettings/meson_post_install.py b/src/modules/gsettings/meson_post_install.py new file mode 100644 index 0000000..0ddb70d --- /dev/null +++ b/src/modules/gsettings/meson_post_install.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 + +import os +import subprocess +import sys + +datadir = sys.argv[1] + +# Package managers set this so we don't need to run +if not os.environ.get('DESTDIR'): + schemadir = os.path.join(datadir, 'glib-2.0', 'schemas') + print('Compiling gsettings schemas...') + subprocess.call(['glib-compile-schemas', schemadir]) + diff --git a/src/modules/gsettings/module-gsettings.c b/src/modules/gsettings/module-gsettings.c new file mode 100644 index 0000000..0822093 --- /dev/null +++ b/src/modules/gsettings/module-gsettings.c @@ -0,0 +1,118 @@ +/*** + This file is part of PulseAudio. + + Copyright 2006 Lennart Poettering + + PulseAudio 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. + + PulseAudio 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 + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, see <http://www.gnu.org/licenses/>. +***/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <sys/types.h> +#include <sys/wait.h> + +#include <pulsecore/core-error.h> +#include <pulsecore/core-util.h> +#include <pulsecore/start-child.h> + +#include "../stdin-util.h" + +PA_MODULE_AUTHOR("Sylvain Baubeau"); +PA_MODULE_DESCRIPTION("GSettings Adapter"); +PA_MODULE_VERSION(PACKAGE_VERSION); +PA_MODULE_LOAD_ONCE(true); + +int pa__init(pa_module*m) { + struct userdata *u; + int r; + + u = pa_xnew(struct userdata, 1); + u->core = m->core; + u->module = m; + m->userdata = u; + u->module_infos = pa_hashmap_new_full(pa_idxset_string_hash_func, pa_idxset_string_compare_func, NULL, (pa_free_cb_t) module_info_free); + u->pid = (pid_t) -1; + u->fd = -1; + u->fd_type = 0; + u->io_event = NULL; + u->buf_fill = 0; + + if ((u->fd = pa_start_child_for_read( +#if defined(__linux__) && defined(HAVE_RUNNING_FROM_BUILD_TREE) +#ifdef MESON_BUILD + pa_run_from_build_tree() ? PA_BUILDDIR PA_PATH_SEP "src" PA_PATH_SEP "modules" PA_PATH_SEP "gsettings" PA_PATH_SEP "gsettings-helper" : +#else + pa_run_from_build_tree() ? PA_BUILDDIR "/gsettings-helper" : +#endif +#endif + PA_GSETTINGS_HELPER, NULL, &u->pid)) < 0) + goto fail; + + u->io_event = m->core->mainloop->io_new( + m->core->mainloop, + u->fd, + PA_IO_EVENT_INPUT, + io_event_cb, + u); + + do { + if ((r = handle_event(u)) < 0) + goto fail; + + /* Read until the client signalled us that it is ready with + * initialization */ + } while (r != 1); + + return 0; + +fail: + pa__done(m); + return -1; +} + +void pa__done(pa_module*m) { + struct userdata *u; + + pa_assert(m); + + if (!(u = m->userdata)) + return; + + if (u->pid != (pid_t) -1) { + kill(u->pid, SIGTERM); + + for (;;) { + if (waitpid(u->pid, NULL, 0) >= 0) + break; + + if (errno != EINTR) { + pa_log("waitpid() failed: %s", pa_cstrerror(errno)); + break; + } + } + } + + if (u->io_event) + m->core->mainloop->io_free(u->io_event); + + if (u->fd >= 0) + pa_close(u->fd); + + if (u->module_infos) + pa_hashmap_free(u->module_infos); + + pa_xfree(u); +} diff --git a/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml b/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml new file mode 100644 index 0000000..9d06383 --- /dev/null +++ b/src/modules/gsettings/org.freedesktop.pulseaudio.gschema.xml @@ -0,0 +1,115 @@ +<schemalist gettext-domain="pulseaudio"> + <!-- The module-groups object is just an entry point to find the individual + module-group objects. --> + <schema id="org.freedesktop.pulseaudio.module-groups" path="/org/freedesktop/pulseaudio/module-groups/"> + <child name="combine" schema="org.freedesktop.pulseaudio.module-group"/> + <child name="remote-access" schema="org.freedesktop.pulseaudio.module-group"/> + <child name="zeroconf-discover" schema="org.freedesktop.pulseaudio.module-group"/> + <child name="raop-discover" schema="org.freedesktop.pulseaudio.module-group"/> + <child name="rtp-recv" schema="org.freedesktop.pulseaudio.module-group"/> + <child name="rtp-send" schema="org.freedesktop.pulseaudio.module-group"/> + <child name="upnp-media-server" schema="org.freedesktop.pulseaudio.module-group"/> + </schema> + + <!-- Paprefs puts related modules into groups that are enabled or disabled as + a whole. One group can contain up to 10 module instances (either of the + same module or different modules). A module-group object defines up to + 10 modules to load. The name0..name9 keys contain the module names and + the args0..args9 keys provide the module arguments. --> + <schema id="org.freedesktop.pulseaudio.module-group"> + <key name="name" type="s"> + <default>''</default> + <summary>Module group name</summary> + <description>Module group name</description> + </key> + + <key name="enabled" type="b"> + <default>false</default> + </key> + + <key name="locked" type="b"> + <default>false</default> + </key> + + <key name="args0" type="s"> + <default>''</default> + </key> + + <key name="args1" type="s"> + <default>''</default> + </key> + + <key name="args2" type="s"> + <default>''</default> + </key> + + <key name="args3" type="s"> + <default>''</default> + </key> + + <key name="args4" type="s"> + <default>''</default> + </key> + + <key name="args5" type="s"> + <default>''</default> + </key> + + <key name="args6" type="s"> + <default>''</default> + </key> + + <key name="args7" type="s"> + <default>''</default> + </key> + + <key name="args8" type="s"> + <default>''</default> + </key> + + <key name="args9" type="s"> + <default>''</default> + </key> + + <key name="name0" type="s"> + <default>''</default> + </key> + + <key name="name1" type="s"> + <default>''</default> + </key> + + <key name="name2" type="s"> + <default>''</default> + </key> + + <key name="name3" type="s"> + <default>''</default> + </key> + + <key name="name4" type="s"> + <default>''</default> + </key> + + <key name="name5" type="s"> + <default>''</default> + </key> + + <key name="name6" type="s"> + <default>''</default> + </key> + + <key name="name7" type="s"> + <default>''</default> + </key> + + <key name="name8" type="s"> + <default>''</default> + </key> + + <key name="name9" type="s"> + <default>''</default> + </key> + </schema> + +</schemalist> diff --git a/src/modules/gsettings/pulseaudio.convert b/src/modules/gsettings/pulseaudio.convert new file mode 100644 index 0000000..d9268bf --- /dev/null +++ b/src/modules/gsettings/pulseaudio.convert @@ -0,0 +1,160 @@ +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/combine/] +args0 = /system/pulseaudio/modules/combine/args0 +args1 = /system/pulseaudio/modules/combine/args1 +args2 = /system/pulseaudio/modules/combine/args2 +args3 = /system/pulseaudio/modules/combine/args3 +args4 = /system/pulseaudio/modules/combine/args4 +args5 = /system/pulseaudio/modules/combine/args5 +args6 = /system/pulseaudio/modules/combine/args6 +args7 = /system/pulseaudio/modules/combine/args7 +args8 = /system/pulseaudio/modules/combine/args8 +args9 = /system/pulseaudio/modules/combine/args9 +name0 = /system/pulseaudio/modules/combine/name0 +name1 = /system/pulseaudio/modules/combine/name1 +name2 = /system/pulseaudio/modules/combine/name2 +name3 = /system/pulseaudio/modules/combine/name3 +name4 = /system/pulseaudio/modules/combine/name4 +name5 = /system/pulseaudio/modules/combine/name5 +name6 = /system/pulseaudio/modules/combine/name6 +name7 = /system/pulseaudio/modules/combine/name7 +name8 = /system/pulseaudio/modules/combine/name8 +name9 = /system/pulseaudio/modules/combine/name9 +enabled = /system/pulseaudio/modules/combine/enabled + +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/remote-access/] +args0 = /system/pulseaudio/modules/remote-access/args0 +args1 = /system/pulseaudio/modules/remote-access/args1 +args2 = /system/pulseaudio/modules/remote-access/args2 +args3 = /system/pulseaudio/modules/remote-access/args3 +args4 = /system/pulseaudio/modules/remote-access/args4 +args5 = /system/pulseaudio/modules/remote-access/args5 +args6 = /system/pulseaudio/modules/remote-access/args6 +args7 = /system/pulseaudio/modules/remote-access/args7 +args8 = /system/pulseaudio/modules/remote-access/args8 +args9 = /system/pulseaudio/modules/remote-access/args9 +name0 = /system/pulseaudio/modules/remote-access/name0 +name1 = /system/pulseaudio/modules/remote-access/name1 +name2 = /system/pulseaudio/modules/remote-access/name2 +name3 = /system/pulseaudio/modules/remote-access/name3 +name4 = /system/pulseaudio/modules/remote-access/name4 +name5 = /system/pulseaudio/modules/remote-access/name5 +name6 = /system/pulseaudio/modules/remote-access/name6 +name7 = /system/pulseaudio/modules/remote-access/name7 +name8 = /system/pulseaudio/modules/remote-access/name8 +name9 = /system/pulseaudio/modules/remote-access/name9 +enabled = /system/pulseaudio/modules/remote-access/enabled + +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/zeroconf-discover/] +args0 = /system/pulseaudio/modules/zeroconf-discover/args0 +args1 = /system/pulseaudio/modules/zeroconf-discover/args1 +args2 = /system/pulseaudio/modules/zeroconf-discover/args2 +args3 = /system/pulseaudio/modules/zeroconf-discover/args3 +args4 = /system/pulseaudio/modules/zeroconf-discover/args4 +args5 = /system/pulseaudio/modules/zeroconf-discover/args5 +args6 = /system/pulseaudio/modules/zeroconf-discover/args6 +args7 = /system/pulseaudio/modules/zeroconf-discover/args7 +args8 = /system/pulseaudio/modules/zeroconf-discover/args8 +args9 = /system/pulseaudio/modules/zeroconf-discover/args9 +name0 = /system/pulseaudio/modules/zeroconf-discover/name0 +name1 = /system/pulseaudio/modules/zeroconf-discover/name1 +name2 = /system/pulseaudio/modules/zeroconf-discover/name2 +name3 = /system/pulseaudio/modules/zeroconf-discover/name3 +name4 = /system/pulseaudio/modules/zeroconf-discover/name4 +name5 = /system/pulseaudio/modules/zeroconf-discover/name5 +name6 = /system/pulseaudio/modules/zeroconf-discover/name6 +name7 = /system/pulseaudio/modules/zeroconf-discover/name7 +name8 = /system/pulseaudio/modules/zeroconf-discover/name8 +name9 = /system/pulseaudio/modules/zeroconf-discover/name9 +enabled = /system/pulseaudio/modules/zeroconf-discover/enabled + +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/raop-discover/] +args0 = /system/pulseaudio/modules/raop-discover/args0 +args1 = /system/pulseaudio/modules/raop-discover/args1 +args2 = /system/pulseaudio/modules/raop-discover/args2 +args3 = /system/pulseaudio/modules/raop-discover/args3 +args4 = /system/pulseaudio/modules/raop-discover/args4 +args5 = /system/pulseaudio/modules/raop-discover/args5 +args6 = /system/pulseaudio/modules/raop-discover/args6 +args7 = /system/pulseaudio/modules/raop-discover/args7 +args8 = /system/pulseaudio/modules/raop-discover/args8 +args9 = /system/pulseaudio/modules/raop-discover/args9 +name0 = /system/pulseaudio/modules/raop-discover/name0 +name1 = /system/pulseaudio/modules/raop-discover/name1 +name2 = /system/pulseaudio/modules/raop-discover/name2 +name3 = /system/pulseaudio/modules/raop-discover/name3 +name4 = /system/pulseaudio/modules/raop-discover/name4 +name5 = /system/pulseaudio/modules/raop-discover/name5 +name6 = /system/pulseaudio/modules/raop-discover/name6 +name7 = /system/pulseaudio/modules/raop-discover/name7 +name8 = /system/pulseaudio/modules/raop-discover/name8 +name9 = /system/pulseaudio/modules/raop-discover/name9 +enabled = /system/pulseaudio/modules/raop-discover/enabled + +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/rtp-recv/] +args0 = /system/pulseaudio/modules/rtp-recv/args0 +args1 = /system/pulseaudio/modules/rtp-recv/args1 +args2 = /system/pulseaudio/modules/rtp-recv/args2 +args3 = /system/pulseaudio/modules/rtp-recv/args3 +args4 = /system/pulseaudio/modules/rtp-recv/args4 +args5 = /system/pulseaudio/modules/rtp-recv/args5 +args6 = /system/pulseaudio/modules/rtp-recv/args6 +args7 = /system/pulseaudio/modules/rtp-recv/args7 +args8 = /system/pulseaudio/modules/rtp-recv/args8 +args9 = /system/pulseaudio/modules/rtp-recv/args9 +name0 = /system/pulseaudio/modules/rtp-recv/name0 +name1 = /system/pulseaudio/modules/rtp-recv/name1 +name2 = /system/pulseaudio/modules/rtp-recv/name2 +name3 = /system/pulseaudio/modules/rtp-recv/name3 +name4 = /system/pulseaudio/modules/rtp-recv/name4 +name5 = /system/pulseaudio/modules/rtp-recv/name5 +name6 = /system/pulseaudio/modules/rtp-recv/name6 +name7 = /system/pulseaudio/modules/rtp-recv/name7 +name8 = /system/pulseaudio/modules/rtp-recv/name8 +name9 = /system/pulseaudio/modules/rtp-recv/name9 +enabled = /system/pulseaudio/modules/rtp-recv/enabled + +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/rtp-send/] +args0 = /system/pulseaudio/modules/rtp-send/args0 +args1 = /system/pulseaudio/modules/rtp-send/args1 +args2 = /system/pulseaudio/modules/rtp-send/args2 +args3 = /system/pulseaudio/modules/rtp-send/args3 +args4 = /system/pulseaudio/modules/rtp-send/args4 +args5 = /system/pulseaudio/modules/rtp-send/args5 +args6 = /system/pulseaudio/modules/rtp-send/args6 +args7 = /system/pulseaudio/modules/rtp-send/args7 +args8 = /system/pulseaudio/modules/rtp-send/args8 +args9 = /system/pulseaudio/modules/rtp-send/args9 +name0 = /system/pulseaudio/modules/rtp-send/name0 +name1 = /system/pulseaudio/modules/rtp-send/name1 +name2 = /system/pulseaudio/modules/rtp-send/name2 +name3 = /system/pulseaudio/modules/rtp-send/name3 +name4 = /system/pulseaudio/modules/rtp-send/name4 +name5 = /system/pulseaudio/modules/rtp-send/name5 +name6 = /system/pulseaudio/modules/rtp-send/name6 +name7 = /system/pulseaudio/modules/rtp-send/name7 +name8 = /system/pulseaudio/modules/rtp-send/name8 +name9 = /system/pulseaudio/modules/rtp-send/name9 +enabled = /system/pulseaudio/modules/rtp-send/enabled + +[org.freedesktop.pulseaudio.module-group:/org/freedesktop/pulseaudio/module-groups/upnp-media-server/] +args0 = /system/pulseaudio/modules/upnp-media-server/args0 +args1 = /system/pulseaudio/modules/upnp-media-server/args1 +args2 = /system/pulseaudio/modules/upnp-media-server/args2 +args3 = /system/pulseaudio/modules/upnp-media-server/args3 +args4 = /system/pulseaudio/modules/upnp-media-server/args4 +args5 = /system/pulseaudio/modules/upnp-media-server/args5 +args6 = /system/pulseaudio/modules/upnp-media-server/args6 +args7 = /system/pulseaudio/modules/upnp-media-server/args7 +args8 = /system/pulseaudio/modules/upnp-media-server/args8 +args9 = /system/pulseaudio/modules/upnp-media-server/args9 +name0 = /system/pulseaudio/modules/upnp-media-server/name0 +name1 = /system/pulseaudio/modules/upnp-media-server/name1 +name2 = /system/pulseaudio/modules/upnp-media-server/name2 +name3 = /system/pulseaudio/modules/upnp-media-server/name3 +name4 = /system/pulseaudio/modules/upnp-media-server/name4 +name5 = /system/pulseaudio/modules/upnp-media-server/name5 +name6 = /system/pulseaudio/modules/upnp-media-server/name6 +name7 = /system/pulseaudio/modules/upnp-media-server/name7 +name8 = /system/pulseaudio/modules/upnp-media-server/name8 +name9 = /system/pulseaudio/modules/upnp-media-server/name9 +enabled = /system/pulseaudio/modules/upnp-media-server/enabled |