2006-07-26 17:36:14 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of PulseAudio.
|
2007-02-13 15:35:19 +00:00
|
|
|
|
|
|
|
|
Copyright 2006 Lennart Poettering
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
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 of the License,
|
|
|
|
|
or (at your option) any later version.
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
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.
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
|
along with PulseAudio; if not, write to the Free Software
|
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
|
USA.
|
|
|
|
|
***/
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
|
|
#include <gconf/gconf-client.h>
|
|
|
|
|
#include <glib.h>
|
|
|
|
|
|
|
|
|
|
#define PA_GCONF_ROOT "/system/pulseaudio"
|
|
|
|
|
#define PA_GCONF_PATH_MODULES PA_GCONF_ROOT"/modules"
|
|
|
|
|
|
|
|
|
|
static void handle_module(GConfClient *client, const char *name) {
|
|
|
|
|
gchar p[1024];
|
2006-07-27 16:50:26 +00:00
|
|
|
gboolean enabled, locked;
|
2006-07-26 17:36:14 +00:00
|
|
|
int i;
|
|
|
|
|
|
2006-07-27 16:50:26 +00:00
|
|
|
snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/locked", name);
|
|
|
|
|
locked = gconf_client_get_bool(client, p, FALSE);
|
|
|
|
|
|
|
|
|
|
if (locked)
|
|
|
|
|
return;
|
|
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/enabled", name);
|
|
|
|
|
enabled = gconf_client_get_bool(client, p, FALSE);
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
printf("%c%s%c", enabled ? '+' : '-', name, 0);
|
|
|
|
|
|
|
|
|
|
if (enabled) {
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
for (i = 0; i < 10; i++) {
|
|
|
|
|
gchar *n, *a;
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/name%i", name, i);
|
|
|
|
|
if (!(n = gconf_client_get_string(client, p, NULL)) || !*n)
|
|
|
|
|
break;
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
snprintf(p, sizeof(p), PA_GCONF_PATH_MODULES"/%s/args%i", name, i);
|
|
|
|
|
a = gconf_client_get_string(client, p, NULL);
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
printf("%s%c%s%c", n, 0, a ? a : "", 0);
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
g_free(n);
|
|
|
|
|
g_free(a);
|
|
|
|
|
}
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
printf("%c", 0);
|
|
|
|
|
}
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
fflush(stdout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void modules_callback(
|
|
|
|
|
GConfClient* client,
|
|
|
|
|
guint cnxn_id,
|
|
|
|
|
GConfEntry *entry,
|
|
|
|
|
gpointer user_data) {
|
|
|
|
|
|
|
|
|
|
const char *n;
|
|
|
|
|
char buf[128];
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
g_assert(strncmp(entry->key, PA_GCONF_PATH_MODULES"/", sizeof(PA_GCONF_PATH_MODULES)) == 0);
|
|
|
|
|
|
|
|
|
|
n = entry->key + sizeof(PA_GCONF_PATH_MODULES);
|
|
|
|
|
|
|
|
|
|
g_strlcpy(buf, n, sizeof(buf));
|
|
|
|
|
buf[strcspn(buf, "/")] = 0;
|
|
|
|
|
|
|
|
|
|
handle_module(client, buf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
GMainLoop *g;
|
|
|
|
|
GConfClient *client;
|
|
|
|
|
GSList *modules, *m;
|
|
|
|
|
|
2006-09-02 15:18:56 +00:00
|
|
|
g_type_init();
|
|
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
if (!(client = gconf_client_get_default()))
|
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
|
|
gconf_client_add_dir(client, PA_GCONF_ROOT, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL);
|
|
|
|
|
gconf_client_notify_add(client, PA_GCONF_PATH_MODULES, modules_callback, NULL, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
modules = gconf_client_all_dirs(client, PA_GCONF_PATH_MODULES, NULL);
|
|
|
|
|
|
|
|
|
|
for (m = modules; m; m = m->next) {
|
|
|
|
|
char *e = strrchr(m->data, '/');
|
|
|
|
|
handle_module(client, e ? e+1 : m->data);
|
|
|
|
|
}
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
g_slist_free(modules);
|
|
|
|
|
|
|
|
|
|
/* Signal the parent that we are now initialized */
|
|
|
|
|
printf("!");
|
|
|
|
|
fflush(stdout);
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
g = g_main_loop_new(NULL, FALSE);
|
|
|
|
|
g_main_loop_run(g);
|
|
|
|
|
g_main_loop_unref(g);
|
2007-05-29 17:24:48 +00:00
|
|
|
|
2006-07-26 17:36:14 +00:00
|
|
|
g_object_unref(G_OBJECT(client));
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
fail:
|
|
|
|
|
return 1;
|
|
|
|
|
}
|