X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/disorder/blobdiff_plain/763d5e6ad88ef3ba1cd1d7742d060e4f1e54c6b8..11f598d144c1e98322090063faa796ec2a5fb470:/lib/client.c diff --git a/lib/client.c b/lib/client.c index 97dde93..27b7beb 100644 --- a/lib/client.c +++ b/lib/client.c @@ -1,6 +1,6 @@ /* * This file is part of DisOrder. - * Copyright (C) 2004, 2005, 2006 Richard Kettlewell + * Copyright (C) 2004, 2005, 2006, 2007 Richard Kettlewell * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -207,11 +207,12 @@ int disorder_connect_sock(disorder_client *c, const char *username, const char *password, const char *ident) { - int fd = -1, fd2 = -1; + int fd = -1, fd2 = -1, nrvec; unsigned char *nonce; size_t nl; const char *res; - char *r; + char *r, **rvec; + const char *algo = "SHA1"; if(!password) { error(0, "no password found"); @@ -243,9 +244,17 @@ int disorder_connect_sock(disorder_client *c, c->ident = xstrdup(ident); if(disorder_simple(c, &r, 0, (const char *)0)) return -1; - if(!(nonce = unhex(r, &nl))) + if(!(rvec = split(r, &nrvec, SPLIT_QUOTES, 0, 0))) + return -1; + if(nrvec > 1) { + algo = *rvec++; + --nrvec; + } + if(!nrvec) + return -1; + if(!(nonce = unhex(*rvec, &nl))) return -1; - if(!(res = authhash(nonce, nl, password))) goto error; + if(!(res = authhash(nonce, nl, password, algo))) goto error; if(disorder_simple(c, 0, "user", username, res, (char *)0)) return -1; c->user = xstrdup(username); @@ -591,6 +600,22 @@ int disorder_tags(disorder_client *c, return disorder_simple_list(c, vecp, nvecp, "tags", (char *)0); } +/** @brief Get recentl added tracks + * @param c Client + * @param vecp Where to store pointer to list + * @param nvecp Where to store count + * @param max Maximum tracks to fetch, or 0 for all available + * @return 0 on success, non-0 on error + */ +int disorder_new_tracks(disorder_client *c, + char ***vecp, int *nvecp, + int max) { + char limit[32]; + + sprintf(limit, "%d", max); + return disorder_simple_list(c, vecp, nvecp, "new", limit, (char *)0); +} + int disorder_set_global(disorder_client *c, const char *key, const char *value) { return disorder_simple(c, 0, "set-global", key, value, (char *)0); @@ -604,6 +629,23 @@ int disorder_get_global(disorder_client *c, const char *key, char **valuep) { return disorder_simple(c, valuep, "get-global", key, (char *)0); } +int disorder_rtp_address(disorder_client *c, char **addressp, char **portp) { + char *r; + int rc, n; + char **vec; + + if((rc = disorder_simple(c, &r, "rtp-address", (char *)0))) + return rc; + vec = split(r, &n, SPLIT_QUOTES, 0, 0); + if(n != 2) { + error(0, "malformed rtp-address reply"); + return -1; + } + *addressp = vec[0]; + *portp = vec[1]; + return 0; +} + /* Local Variables: c-basic-offset:2