client-conf: refactor cookie loaders

Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
This commit is contained in:
Alexander Couzens 2013-08-21 13:48:12 +02:00 committed by Tanu Kaskinen
parent bf9b3f0720
commit dac6a74155
3 changed files with 51 additions and 19 deletions

View file

@ -91,20 +91,10 @@ int pa_client_conf_from_x11(pa_client_conf *c, const char *dname) {
}
if (pa_x11_get_prop(xcb, screen, "PULSE_COOKIE", t, sizeof(t))) {
uint8_t cookie[PA_NATIVE_COOKIE_LENGTH];
if (pa_parsehex(t, cookie, sizeof(cookie)) != sizeof(cookie)) {
if (pa_client_conf_load_cookie_from_hex(c, t) < 0) {
pa_log(_("Failed to parse cookie data"));
goto finish;
}
pa_assert(sizeof(cookie) == sizeof(c->cookie));
memcpy(c->cookie, cookie, sizeof(cookie));
c->cookie_valid = true;
pa_xfree(c->cookie_file);
c->cookie_file = NULL;
}
ret = 0;