]> code.delx.au - pulseaudio/blob - src/pulse/client-conf-x11.c
remove all occurences of
[pulseaudio] / src / pulse / client-conf-x11.c
1 /* $Id$ */
2
3 /***
4 This file is part of PulseAudio.
5
6 PulseAudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
10
11 PulseAudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-13071
19 USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <string.h>
27 #include <assert.h>
28
29 #include <X11/Xlib.h>
30 #include <X11/Xatom.h>
31
32 #include <pulse/xmalloc.h>
33
34 #include <pulsecore/x11prop.h>
35 #include <pulsecore/log.h>
36 #include <pulsecore/core-util.h>
37
38 #include "client-conf-x11.h"
39
40 int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
41 Display *d = NULL;
42 int ret = -1;
43 char t[1024];
44
45 if (!dname && !getenv("DISPLAY"))
46 goto finish;
47
48 if (!(d = XOpenDisplay(dname))) {
49 pa_log("XOpenDisplay() failed");
50 goto finish;
51 }
52
53 if (pa_x11_get_prop(d, "PULSE_SERVER", t, sizeof(t))) {
54 pa_xfree(c->default_server);
55 c->default_server = pa_xstrdup(t);
56 }
57
58 if (pa_x11_get_prop(d, "PULSE_SINK", t, sizeof(t))) {
59 pa_xfree(c->default_sink);
60 c->default_sink = pa_xstrdup(t);
61 }
62
63 if (pa_x11_get_prop(d, "PULSE_SOURCE", t, sizeof(t))) {
64 pa_xfree(c->default_source);
65 c->default_source = pa_xstrdup(t);
66 }
67
68 if (pa_x11_get_prop(d, "PULSE_COOKIE", t, sizeof(t))) {
69 uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
70
71 if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
72 pa_log("failed to parse cookie data");
73 goto finish;
74 }
75
76 assert(sizeof(cookie) == sizeof(c->cookie));
77 memcpy(c->cookie, cookie, sizeof(cookie));
78
79 c->cookie_valid = 1;
80
81 pa_xfree(c->cookie_file);
82 c->cookie_file = NULL;
83 }
84
85 ret = 0;
86
87 finish:
88 if (d)
89 XCloseDisplay(d);
90
91 return ret;
92
93 }