]>
code.delx.au - pulseaudio/blob - polyp/pax11publish.c
f151c1976339482b04ffc05a23f4c599675383f3
4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU 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.
11 polypaudio 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.
16 You should have received a copy of the GNU General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
32 #include <X11/Xatom.h>
37 #include "native-common.h"
38 #include "client-conf.h"
41 int main(int argc
, char *argv
[]) {
42 const char *dname
= NULL
, *sink
= NULL
, *source
= NULL
, *server
= NULL
, *cookie_file
= PA_NATIVE_COOKIE_FILE
;
45 enum { DUMP
, EXPORT
, IMPORT
, REMOVE
} mode
= DUMP
;
47 while ((c
= getopt(argc
, argv
, "deiD:S:O:I:c:hr")) != -1) {
53 printf("%s [-D display] [-S server] [-O sink] [-I source] [-c file] [-d|-e|-i|-r]\n\n"
54 " -d Show current Polypaudio data attached to X11 display (default)\n"
55 " -e Export local Polypaudio data to X11 display\n"
56 " -i Import Polypaudio data from X11 display to local environment variables and cookie file.\n"
57 " -r Remove Polypaudio data from X11 display\n",
58 pa_path_get_filename(argv
[0]));
86 fprintf(stderr
, "Failed to parse command line.\n");
91 if (!(d
= XOpenDisplay(dname
))) {
92 pa_log(__FILE__
": XOpenDisplay() failed\n");
99 if (!pa_x11_get_prop(d
, "POLYP_SERVER", t
, sizeof(t
)))
102 printf("Server: %s\n", t
);
103 if (pa_x11_get_prop(d
, "POLYP_SOURCE", t
, sizeof(t
)))
104 printf("Source: %s\n", t
);
105 if (pa_x11_get_prop(d
, "POLYP_SINK", t
, sizeof(t
)))
106 printf("Sink: %s\n", t
);
107 if (pa_x11_get_prop(d
, "POLYP_COOKIE", t
, sizeof(t
)))
108 printf("Cookie: %s\n", t
);
115 if (!pa_x11_get_prop(d
, "POLYP_SERVER", t
, sizeof(t
)))
118 printf("POLYP_SERVER='%s'\nexport POLYP_SERVER\n", t
);
120 if (pa_x11_get_prop(d
, "POLYP_SOURCE", t
, sizeof(t
)))
121 printf("POLYP_SOURCE='%s'\nexport POLYP_SOURCE\n", t
);
122 if (pa_x11_get_prop(d
, "POLYP_SINK", t
, sizeof(t
)))
123 printf("POLYP_SINK='%s'\nexport POLYP_SINK\n", t
);
125 if (pa_x11_get_prop(d
, "POLYP_COOKIE", t
, sizeof(t
))) {
126 uint8_t cookie
[PA_NATIVE_COOKIE_LENGTH
];
128 if ((l
= pa_parsehex(t
, cookie
, sizeof(cookie
))) != sizeof(cookie
)) {
129 fprintf(stderr
, "Failed to parse cookie data\n");
133 if (pa_authkey_save(cookie_file
, cookie
, l
) < 0) {
134 fprintf(stderr
, "Failed to save cookie data\n");
143 struct pa_client_conf
*c
= pa_client_conf_new();
144 uint8_t cookie
[PA_NATIVE_COOKIE_LENGTH
];
145 char hx
[PA_NATIVE_COOKIE_LENGTH
*2+1];
148 if (pa_client_conf_load(c
, NULL
) < 0) {
149 fprintf(stderr
, "Failed to load client configuration file.\n");
153 if (pa_client_conf_env(c
) < 0) {
154 fprintf(stderr
, "Failed to read environment configuration data.\n");
158 pa_x11_del_prop(d
, "POLYP_ID");
161 pa_x11_set_prop(d
, "POLYP_SERVER", c
->default_server
);
162 else if (c
->default_server
)
163 pa_x11_set_prop(d
, "POLYP_SERVER", c
->default_server
);
166 if (!pa_get_fqdn(hn
, sizeof(hn
))) {
167 fprintf(stderr
, "Failed to get FQDN.\n");
171 pa_x11_set_prop(d
, "POLYP_SERVER", hn
);
175 pa_x11_set_prop(d
, "POLYP_SINK", sink
);
176 else if (c
->default_sink
)
177 pa_x11_set_prop(d
, "POLYP_SINK", c
->default_sink
);
180 pa_x11_set_prop(d
, "POLYP_SOURCE", source
);
181 if (c
->default_source
)
182 pa_x11_set_prop(d
, "POLYP_SOURCE", c
->default_source
);
184 pa_client_conf_free(c
);
186 if (pa_authkey_load_auto(cookie_file
, cookie
, sizeof(cookie
)) < 0) {
187 fprintf(stderr
, "Failed to load cookie data\n");
191 pa_x11_set_prop(d
, "POLYP_COOKIE", pa_hexstr(cookie
, sizeof(cookie
), hx
, sizeof(hx
)));
196 pa_x11_del_prop(d
, "POLYP_SERVER");
197 pa_x11_del_prop(d
, "POLYP_SINK");
198 pa_x11_del_prop(d
, "POLYP_SOURCE");
199 pa_x11_del_prop(d
, "POLYP_ID");
200 pa_x11_del_prop(d
, "POLYP_COOKIE");
204 fprintf(stderr
, "No yet implemented.\n");