From dbaa83c60730633315aa13d74907c6572985c050 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Tue, 9 Nov 2004 23:19:42 +0000 Subject: split out x11prop.[ch] add client support for auth daemon info in X display git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@279 fefdeb5f-60dc-0310-8127-8f9354f1896f --- polyp/module-x11-publish.c | 51 +++++++++++----------------------------------- 1 file changed, 12 insertions(+), 39 deletions(-) (limited to 'polyp/module-x11-publish.c') diff --git a/polyp/module-x11-publish.c b/polyp/module-x11-publish.c index c862fe3a..6e100153 100644 --- a/polyp/module-x11-publish.c +++ b/polyp/module-x11-publish.c @@ -45,6 +45,7 @@ #include "module-x11-publish-symdef.h" #include "authkey-prop.h" #include "authkey.h" +#include "x11prop.h" PA_MODULE_AUTHOR("Lennart Poettering") PA_MODULE_DESCRIPTION("X11 Credential Publisher") @@ -68,34 +69,6 @@ struct userdata { int auth_cookie_in_property; }; -static void set_x11_prop(Display *d, const char *name, const char *data) { - Atom a = XInternAtom(d, name, False); - XChangeProperty(d, RootWindow(d, 0), a, XA_STRING, 8, PropModeReplace, (unsigned char*) data, strlen(data)+1); -} - -static void del_x11_prop(Display *d, const char *name) { - Atom a = XInternAtom(d, name, False); - XDeleteProperty(d, RootWindow(d, 0), a); -} - -static char* get_x11_prop(Display *d, const char *name, char *p, size_t l) { - Atom actual_type; - int actual_format; - unsigned long nitems; - unsigned long nbytes_after; - unsigned char *prop; - - Atom a = XInternAtom(d, name, False); - if (XGetWindowProperty(d, RootWindow(d, 0), a, 0, (l+2)/4, False, XA_STRING, &actual_type, &actual_format, &nitems, &nbytes_after, &prop) != Success) - return NULL; - - memcpy(p, prop, nitems); - p[nitems] = 0; - - XFree(prop); - return p; -} - static int load_key(struct userdata *u, const char*fn) { assert(u); @@ -155,16 +128,16 @@ int pa__init(struct pa_core *c, struct pa_module*m) { u->id = pa_sprintf_malloc("%s@%s/%u", un, hn, (unsigned) getpid()); - set_x11_prop(u->display, "POLYP_SERVER", hn); - set_x11_prop(u->display, "POLYP_ID", u->id); + pa_x11_set_prop(u->display, "POLYP_SERVER", hn); + pa_x11_set_prop(u->display, "POLYP_ID", u->id); if ((t = pa_modargs_get_value(ma, "source", NULL))) - set_x11_prop(u->display, "POLYP_SOURCE", t); + pa_x11_set_prop(u->display, "POLYP_SOURCE", t); if ((t = pa_modargs_get_value(ma, "sink", NULL))) - set_x11_prop(u->display, "POLYP_SINK", t); + pa_x11_set_prop(u->display, "POLYP_SINK", t); - set_x11_prop(u->display, "POLYP_COOKIE", pa_hexstr(u->auth_cookie, sizeof(u->auth_cookie), hx, sizeof(hx))); + pa_x11_set_prop(u->display, "POLYP_COOKIE", pa_hexstr(u->auth_cookie, sizeof(u->auth_cookie), hx, sizeof(hx))); pa_modargs_free(ma); return 0; @@ -188,14 +161,14 @@ void pa__done(struct pa_core *c, struct pa_module*m) { char t[256]; /* Yes, here is a race condition */ - if (!get_x11_prop(u->display, "POLYP_ID", t, sizeof(t)) || strcmp(t, u->id)) + if (!pa_x11_get_prop(u->display, "POLYP_ID", t, sizeof(t)) || strcmp(t, u->id)) pa_log("WARNING: Polypaudio information vanished from X11!\n"); else { - del_x11_prop(u->display, "POLYP_ID"); - del_x11_prop(u->display, "POLYP_SERVER"); - del_x11_prop(u->display, "POLYP_SINK"); - del_x11_prop(u->display, "POLYP_SOURCE"); - del_x11_prop(u->display, "POLYP_COOKIE"); + pa_x11_del_prop(u->display, "POLYP_ID"); + pa_x11_del_prop(u->display, "POLYP_SERVER"); + pa_x11_del_prop(u->display, "POLYP_SINK"); + pa_x11_del_prop(u->display, "POLYP_SOURCE"); + pa_x11_del_prop(u->display, "POLYP_COOKIE"); XSync(u->display, False); } } -- cgit